This paper illustrates the Laravel Routing and Sub routing settings. Share to everyone for your reference, specific as follows:
Common 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 to filename (class name)
@index is the 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. Route:
Route::group ([' Namespace ' => ' Min '], function () {
route::get (' Min/{index} ', ' Mincontroller@index ');
Here the {index} is similar to regular, that is, the URL can be randomly lost: 127.0.0.1/min/$index is like a variable, you can lose anything. But the back of the @index 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 below the Min view folder
}
}
Structure Chart:
More interested in laravel related content readers can view the site topics: "Laravel Framework Introduction and Advanced Course", "PHP Excellent Development Framework Summary", "Smarty Template Primer Tutorial", "PHP date and Time usage summary", "PHP object-oriented Program Design Introductory Course ", PHP string (String) Usage summary," PHP+MYSQL Database operation Introduction Tutorial "and" PHP common database Operation Skills Summary "
I hope this article will help you with the PHP program design based on Laravel framework.