Skip to content
Advertisement

How to override Laravel default routes with my package

I have developed a package and published it to packagist. My package contains a service provider and a set of routes including default ‘/’ route which are loaded through service provider class’ boot method.

$this->loadRoutesFrom(__DIR__.'/routes.php');

However, instead of default route from package the default route from web.php gets executed whenever I visit the site. Also other routes from the package seem to work fine. What’s the issue in this case?

Advertisement

Answer

You can not override from Laravel package. The solution is just ask your package user to remove your defined route in default route file(web.php).

Or you could override from middleware like this package https://github.com/awjudd/maintenance-mode ,

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement