BennyCarlsson / MyPortfolio-Hacktoberfest2019

I'm in need for a new portfolio website. Maybe the Hacktoberfest army could help me?
https://bennycarlsson.github.io/MyPortfolio-Hacktoberfest2019/
MIT License
106 stars 228 forks source link

laravel routes conflict #274

Closed lejober95 closed 5 years ago

lejober95 commented 5 years ago

I try to set up route localhost:8000/vers or localhost:8000/register in laravel using following routes: route but when i go to localhost:8000/vers or localhost:8000/register it runs the localhost:8000/test or the localhost /voir_doc/{voirmat} . please help , i get troubled

==> je ne cesse de me troubler, S'il vous plait aidez moi, quand j'essaie de lancer <<localhost:8000/vers ou localhost:8000/register>> ce sont les routes << localhost:8000/test ou localhost:8000>> qui répondent en lieu et place en tout cas les routes <> ne répondent pas

lejober95 commented 5 years ago

Please I need help

vxzry commented 5 years ago

hi, this is caused by the order of your routes; Laravel goes through the routes from top to bottom.

Placing the Route::get('/test?', 'EtudController@test'); on top which has an optional parameter test?, makes your other routes (/vers and /register) unreachable.

Any entries after the / is assumed as the parameter for your Route::get('/test?', 'EtudController@test'); route

You could try rearranging your routes.

lejober95 commented 5 years ago

Hi thank you but explain me a little bit this way to do

makes your other routes (/vers and /register) unreachable. how? by deleting the "/" ?

lejober95 commented 5 years ago

hi, this is caused by the order of your routes; Laravel goes through the routes from top to bottom.

Placing the Route::get('/test?', 'EtudController@test'); on top which has an optional parameter test?, makes your other routes (/vers and /register) unreachable.

Any entries after the / is assumed as the parameter for your Route::get('/test?', 'EtudController@test'); route

You could try rearranging your routes.

Hi thank you but explain me a little bit this way to do

makes your other routes (/vers and /register) unreachable. how? by deleting the "/" ?

vxzry commented 5 years ago

It takes the words "vers" and "register" as an input for your test parameter. You could try printing the request from the test method on your controller to see if it will print those words.

makes your other routes (/vers and /register) unreachable. how? by deleting the "/" ?

your first route expects an input after the slash. Meaning, if you went to /foo, the word foo is taken as the parameter for your first route. Same thing will happen if you went to /vers and /register since it's the first thing it will see on the routes with the same format.