giuga/laravel-ordered-routes
Composer 安装命令:
composer require giuga/laravel-ordered-routes
包简介
Set order for routes defined in web.php
README 文档
README
Add order to routes
Install the package
composer require giuga/laravel-ordered-routes
Change the default application loaded in bootstrap/app.php
Find
$app = new \Illuminate\Foundation\Application( realpath(__DIR__.'/../') );
Replace with
$app = new \Giuga\Application( realpath(__DIR__.'/../') );
Change the default Route alias in config/app.php
Find
'aliases' => [ ... 'Route' => Illuminate\Support\Facades\Route::class, ...
Replace with
'aliases' => [ ... 'Route' => Giuga\Routing\Facades\OrderRoute::class, ...
routes/web.php
By using this package you have the ability to define routes in what ever order you want.
In the example below the {slug?} would catch also the home route even if this was not our intention. By defining an order, if the requested url matches a predefined route like /home and /home does not have a higher order number than {slug?} home will be used.
Route:get('{slug?}', function($slug){ return $slug; } )->name('named.slug')->order(999); Route:get('/home'), function(){ return 'This is my Home'; })->name('home');
统计信息
- 总下载量: 405
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-10-29