Home > Article > PHP Framework > Detailed explanation about laravel automatic routing
The following tutorial column will introduce laravel automatic routing to you. I hope it will be helpful to friends in need!
1. Function
Advantages 1. Automatically match the controllerFor example:
URL: localhost/home/hello/index/id/name/……composer require xindong888/laravel-router
Controller: App\Http\Controllers\Hello.phpMethod: index is the method under Hello.php
Parameters: id, name... are all parameters, automatically matched to the parameters in the controller method
Advantage 2. Routing can be configured in the original routes->api.php and routes->web.phpAdvantage 3. Routes specified in api or web will be matched first
## 2. Installation
3. Usage method one1. Use composer to load composer require xindong888/laravel-router
2. Enter the configuration folder config->app.php<?php
[
'providers' => [
//.................注释掉原有的路由服务提供者
//App\Providers\RouteServiceProvider::class,
//.................添加万能路由服务提供者
xindong888\Laravel\Providers\RouteServiceProvider::class
]]
?>
four .Usage method two
1. Use app->Providers->RouteServiceProvider to inherit xindong888\Laravel\Providers\RouteServiceProvider
2. Clean up the code in boot() and add parent::boot() ;
class RouteServiceProvider extends \xindong888\Laravel\Providers\RouteServiceProvider { public function boot() { parent::boot(); } }Related recommendations:
The latest five Laravel video tutorials
The above is the detailed content of Detailed explanation about laravel automatic routing. For more information, please follow other related articles on the PHP Chinese website!