Laravel Route setting and sub-route setting example analysis, laravel example Analysis _php tutorial

Source: Internet
Author: User
Tags smarty template

Laravel Route setting and sub-route setting example analysis, laravel instance analysis


This paper describes the Laravel routing and sub-route setting methods. Share to everyone for your reference, as follows:

Normal routing settings

1. Routing (routes.php) code:

Route::get (' min ', ' mincontroller@index ');

Min: For the route name, which is entered in the URL, such as 127.0.0.1/min here min is the corresponding min
Mincontroller as file name (class name)
@index as Method name

2. Controller

Namespace App\http\controllers;use app\http\controllers\controller;class Mincontroller extends controller{  Public Function Index () {     $name = ' Specs1 ';    Return view (' index ')->with (' name ', $name);}  }

Sub-route

1. Routing:

Route::group ([' namespace ' = ' Min '], function () {  route::get (' Min/{index} ', ' Mincontroller@index ');  Here the {index} is similar to the regular, that is, the URL can be randomly lost: 127.0.0.1/min/$index like a variable, you can lose anything. But the @index in the back is the Real method});

Controller:

Namespace App\http\controllers\min;//min is the controller's folder path use App\http\controllers\controller;class Mincontroller extends controller{Public  Function Index () {     $name = ' Specs1 ';    Return view (' Min.index ')->with (' name ', $name);//The min.index here is equivalent to Min/index  is the index.blade.php file under the Min view folder  }}

Structure diagram:

More interested in laravel related content readers can view this site topic: "Laravel Framework Introductory and Advanced tutorial", "PHP Excellent Development Framework Summary", "Smarty Template Primer Basic Tutorial", "PHP date and Time usage summary", "PHP object-oriented Programming introduction tutorial "," PHP String Usage Summary "," Introduction to Php+mysql Database Operations "and" PHP common database Operation Skills Summary "

It is hoped that this article is helpful to the PHP program design based on Laravel framework.

Articles you may be interested in:

    • Introduction to routing, controllers, and views of Laravel 5 Framework Learning
    • thinkphp, ZF2, YAF, laravel framework routing big battle
    • Laravel 4 View, namespaces, routes for the beginner tutorial
    • Follow me on the route to Laravel.
    • Laravel Framework Routing configuration summary, Setup tips Daquan
    • Laravel5.1 a database connection, creating a database, creating a model, and creating a controller
    • A detailed example of trait usage in Laravel
    • Laravel method of implementing automatic dependency injection of constructors
    • Create an App interface (API) based on Laravel
    • PHP Framework Laravel Learning Experience
    • Get previous and next data in Laravel

http://www.bkjia.com/PHPjc/1117066.html www.bkjia.com true http://www.bkjia.com/PHPjc/1117066.html techarticle Laravel Route setting and sub-route setting example analysis, laravel instance analysis the Laravel route setting and sub-route setting method are described in this paper. Share to everyone for your reference, as follows ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.