Home > PHP Framework > Laravel > Detailed explanation about laravel automatic routing

Detailed explanation about laravel automatic routing

藏色散人
Release: 2021-06-17 09:04:01
forward
2426 people have browsed it

The following tutorial column will introduce laravel automatic routing to you. I hope it will be helpful to friends in need!

Detailed explanation about laravel automatic routing                                                                                                                                          

1. Function

Advantages 1. Automatically match the controllerFor example:

URL: localhost/home/hello/index/id/name/……


Controller: App\Http\Controllers\Hello.php

Method: 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.php

Advantage 3. Routes specified in api or web will be matched first



## 2. Installation

composer require xindong888/laravel-router

3. Usage method one

1. Use composer to load composer require xindong888/laravel-router

2. Enter the configuration folder config->app.php

<?php
[
&#39;providers&#39; => [
//.................注释掉原有的路由服务提供者
//App\Providers\RouteServiceProvider::class,
//.................添加万能路由服务提供者
xindong888\Laravel\Providers\RouteServiceProvider::class
]]
?>
Copy after login
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();
    }
}
Copy after login

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!

Related labels:
source:learnku.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template