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.