I have a Laravel 5.8 application and I need to add a custom anonymous route to the Laravel’s core file which is Router.php and located in this directory:
/vendor/laravel/framework/src/Illuminate/Routing
I checked the file but since it does not have any map
method, so I couldn’t define the route.
So the question is how can I add the route in this case?
2
Answers
What about adding a line like:
as last line in the __construct() method of /vendor/laravel/framework/src/Illuminate/Routing/Route.php ?
Go to this file
app/Providers/RouteServiceProvider
and add this method:And on the
map
method, add the newly created method$this->mapHiddenRoutes()
.Then you can go on your browser and visit
{domain}/hidden/secret