Laravel 5.4 - How to override route defined in a package?

后端 未结 2 2031
我在风中等你
我在风中等你 2021-02-06 04:36

I have created a package in Laravel 5.4 that sets up a basic backoffice. This package contains several routes that are using controllers from within the package. What I want to

2条回答
  •  野性不改
    2021-02-06 04:56

    In config/app.php in the providers array put the service provider of the package before App\Providers\RouteServiceProvider::class, and then in your web.php routes you'll be able to override it with your custom route.

    EDIT For Laravel package auto discovery you can disable the package being auto discovered in your composer.json like this:

    "extra": {
        "laravel": {
            "dont-discover": [
                "barryvdh/laravel-debugbar"
            ]
        }
    },
    

    In this example the barryvdh/laravel-debugbar package won't be autodiscovered, which means you would have to manually include its service provider in the config array and then you'll be able to rearrange your custom provider in the desired order.

提交回复
热议问题