vendredi 29 décembre 2017

Strange behaviour in laravel routing

Consider the two following laravel routing directives:

    Route::get('/a/b', function(){return "One";});
     .
     .
     .
    Route::get('/a/b', function(){return "Two";});

I know they don't make much sense, but consider them. Theoretically, the priority is that the first one would prevail over the second. But if you access the site with

http://whatever.com/a/b

the response is

Two

I guess this happens because even if the real selected directive is the first, it happened that the second one OVERWROTE the first one with his return value.

My question is: Is this the intended behaviour? Because it may be obvious when you only have two lines in your routes file, but not when you have dozens of them, and you inadvertly could duplicate the same directive and think that the return value of the first one is the one to be returned.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire