Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Laravel Route Not Defined Checklist

We’ve all had this error, and it’s pretty annoying, to say the least. It always seems we’ve done everything right and once we try to render the page, the almighty Route Not Defined error is produced.

It usually looks like the screenshot below –

Checklist

When you come across this error in Laravel, make sure to check the following parts of your application

1. Web.php

Ensure that the route you are trying to render has had a proper route setup in this file. The route must be named and therefore, should look like the following –

Route::get('/dashboard', 'MyController@dashboard')->name('dashboard');

Notice the ->name('dashboard') part of this routes syntax, this is of extreme importance to be correctly defined if you want to use the route() function to generate URLs.

2. View or Controller files

Lastly, you must ensure that the route function parameter matches the name exactly as defined in the web.php file. For example,

In a view

Dashboard

In a controller

$url = route('dashboard');

Summary

Hope this helps, keep this checklist handy for the next time this happens, this common mistake is easy to miss when developing! For further reading on Laravel named routes, you can check out the documentation here.

The post Laravel Route Not Defined Checklist appeared first on Code Wall.



This post first appeared on Code Wall - Web Development & Programming, please read the originial post: here

Share the post

Laravel Route Not Defined Checklist

×

Subscribe to Code Wall - Web Development & Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×