vildanbina/route-priority is a Laravel package for package to add priority to laravel 7 routes.
It currently has 0 GitHub stars and 1 downloads on Packagist.
Install it with composer require vildanbina/route-priority.
Discover more Laravel packages by vildanbina
or browse all Laravel packages to compare alternatives.
Last updated
You can install the package via composer:
composer require vildanbina/route-priority
Now open up app/config/app.php and add the service provider to your providers array.
vildanbina\RoutePriority\RoutePriorityServiceProvider::class,
Add the trait to App\Http\Kernel
use \vildanbina\RoutePriority\RouterTrait;
Change routes priority:
Route::get('test', ['uses' => 'Controller@showAction'])->setPriority(100);
Default priority is 50. Higher priority - values from 50 and above, lower priority - 49 and below.
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.
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.