如何将捕获所有路由设置为 Laravel 中的最后一条路由

How can I set a catch all route as the very last route in Laravel

我正在构建一个带有 SEO slug 的基本 CMS,所以我想在我的路线末尾捕获所有东西以获取 slug。所以在我的路线文件的末尾,我添加了:

Route::get('/{page?}', ['as' => 'Page', 'middleware' => 'web', 'uses' => 'PageController@index']);

效果很好,直到我添加了 Laravel File Manager,它有自己的路线。这些路线被添加到 我的主路线文件中的所有路线之后。所以现在我的 catch all 收集了文件管理器的任何内容。

如何在 运行 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,

],

只需像这样尝试对 app.php 中的服务提供商重新排序:

'providers' => [

    /*
     * Laravel Framework Service Providers...
     */

    Unisharp\Laravelfilemanager\LaravelFilemanagerServiceProvider::class,
    ... 
    App\Providers\RouteServiceProvider::class,
    ... 

],

无论如何我总是在列表的末尾写RouteServiceProvider,如果不是特殊情况