mprince2k18/route-priority
Composer 安装命令:
composer require mprince2k18/route-priority
包简介
Package to add priority to Laravel 10 routes
关键字:
README 文档
README
Installation
-
Add
mprincek18/route-prioritytocomposer.json.composer require mprincek18/route-priority
2)Run composer update to pull down the latest version of the package.
3)Now open up app/config/app.php and add the service provider to your providers array.
Mprince\RoutePriority\RoutePriorityServiceProvider::class,
4)Add the trait to App\Http\Kernel
use \Mprince\RoutePriority\RouterTrait;
Usage
Change routes priority:
Route::get('test', ['uses' => 'Controller@showAction'])->setPriority(100);
Default Priority
Default priority is 50. Higher priority - values from 50 and above, lower priority - 49 and below.
Usage example
Route::get('/test/{slug}', …); Route::get('/test/hello', …);
In this example second route will not work. Add priority 0 to the first route will fix the error:
Route::get('/test/{slug}', …)->setPriority(0); Route::get('/test/hello', …);
Second route now has higher priority.
Group priority
You can put priority to groups:
Route::group(['prefix' => 'test-group', 'priority' => 10], function () { Route::get('/test/hello', function () { return 'First group'; }); }); Route::group(['prefix' => 'test-group', 'priority' => 20], function () { Route::get('/test/hello', function () { return 'Second group'; }); });
Second group has higher priority then First group. All routes in the group will has the same priority as the group.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-03-22