我正在使用SEO slugs建立一个基本的CMS,所以我希望在我的路线末端捕获所有以获得slug。所以在我的路线文件的末尾我添加了:
Route::get('/{page?}', ['as' => 'Page', 'middleware' => 'web', 'uses' => 'PageController@index']);
哪个工作正常,直到我添加了Laravel File Manager,它有自己的路由。这些路由在之后添加在我的主路由文件中的所有路由之后。所以现在我的所有人都会选择任何适合文件管理器的东西。
如何在运行catch all之前加载所有其他路由,包括其他供应商文件夹中的路由?有没有办法可以说明路线必须与前缀为laravel-filemanager
的任何路线不匹配?我无法在Laravel文档中或通过Google找到任何相关内容。
这里要求的是我的应用提供商:
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
Caffeinated\Modules\ModulesServiceProvider::class,
Intervention\Image\ImageServiceProvider::class,
Spatie\Activitylog\ActivitylogServiceProvider::class,
Spatie\Permission\PermissionServiceProvider::class,
Unisharp\Ckeditor\ServiceProvider::class,
Unisharp\Laravelfilemanager\LaravelFilemanagerServiceProvider::class,
],
答案 0 :(得分:3)
只需尝试重新排序app.php中的服务提供商,如下所示:
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Unisharp\Laravelfilemanager\LaravelFilemanagerServiceProvider::class,
...
App\Providers\RouteServiceProvider::class,
...
],
无论如何,我总是在列表末尾写RouteServiceProvider
,如果不是特殊情况