My routes don't work

Hello everyone,

I am making a custom cms but I cannot get my routes to work. Here is a gist to my routing file and my controller.

basically the dashboard controller is made using : php artisan make:controller : but I modified it.
Can somebody help me ?

https://gist.github.com/concept-core/0357c0d08fafbd01ddc1

Why are there two opening <?php tags at the beginning of the controller?

Because I did not notice I needed to delete the top one since I copy pasted it.
my fault but not the reason why it does not work :smile:

I kinda figured it out.
My top route for dashboard has : {type?} and {list?} which makes laravel somehow conflict with the second route.

If Laravel routes are similar to Symfony’s, then the sequence they are in matters, because the routes are checked in a top down fashion.

I couldn’t find any mention about route sequence in the Laravel docs. But here, from the Symfony docs (which are tons better than the Laravel docs).

Earlier Routes always Win

What this all means is that the order of the routes is very important. If the blog_show route were placed above the blog route, the URL /blog/2 would match blog_show instead of blog since the {slug} parameter of blog_show has no requirements. By using proper ordering and clever requirements, you can accomplish just about anything.

Scott

I also had problems with Laravel routes.php because I was used to CodeIgniter’s way of defining routes.

I have this reminder at the top of my Laravel routes.php file:

// ----------------------------------------------
//  GETS LEAST FIRST NOT LIKE CodeIgniter !!!!
// ----------------------------------------------
Route::post('dashboard/{type?}', 'DashboardController@store');

Route::get('dashboard/{type?}/create', 'DashboardController@create');

I would be tempted to start with no routes and add them one at a time :slight_smile:

I am not sure but I think CodeIgniter ver: 3.03 has changed the order of the routes.php and now it is similar to Laravel.

Thanks for the tip I will try this out.

1 Like

Did not work, I will create a new method and a new route for my dashboard :smile:

Is your .htaccess script correct? Have you tried a simple Rewrite rule?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.