Skip to content
Advertisement

Updates to Laravel route file have no effect

I am trying to create a view to display data from the database but I discovered that my route file doesn’t do anything anymore.

At the moment I am trying to get the test function working but when I go to /test it just says “Page not found”. The other routes work. Even if I delete all of the contents and save the file, all the other routes work.

I have tried artisan route:clear, artisan cache:clear and so on but nothing works.

This is my route file.

Route::get('/test', function () {
    return "ok";
});//this is not workig

Route::get( '/', function () {
    return view( 'welcome' );
} );

Route::resource( 'submission', 'SubmissionController' );

Advertisement

Answer

When you execute php artisan route:cache, Laravel creates a cached routes file in the bootstrap/cache/routes.php directory. While this file exists all your other apps route files will be ignored.

Anytime you create new routes you will need to re-generate the routes cache by executing php artisan route:cache.

If you need to remove the route cache you can execute php artisan route:clear.

If the above fails to solve your problem, it could indicate a permissions problem. Make sure the bootstrap/cache directory has the correct permissions to be altered/deleted.

Failing that, you could manually delete the bootstrap/cache/routes.php file yourself.

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