Search code examples
laravelrouteslumen

Laravel / Lumen update to 5.5, routing broken


I have upgraded my Lumen project to 5.5 version and routing seems to be broken. Every URL I type is returning the default '/' route defined as :

$router->get('/', function () use ($router) {
    return $router->app->version();
});

When trying to hit /example lumen does not triggers a 404 error, it just returns the content of my '/' route.

It is not a web-server configuration issue : as it was working fine prior to the upgrade, and still works just fine for other lumen projects running versions from 5.2 to 5.6.

Yes, the /routes/web.php is defined in /config/app.php as the route file

After a few tests, it turns out that the request uri always appears to Lumen as "/". When I print the $method and $pathInfo from the "/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php" on line 156 it gives me

string(3) "GET" # for $method
string(1) "/" # for $pathInfo

So my question is, are there any changes that I missed from the documentation that needs to be performed on request class ? Why does this happens ? Do I need to create a project from scratch and just move my controllers ?

Thank you for your time!

UPDATE: as requested by Styx, here is the webserver configuration, Im' using the same configuration for lots of Lumen projects running on various versions and routing is not an issue on any of them, except the one we are talking about.

For directory holding all projects :

<Directory "C:\Users\[user]\Desktop\projets">
    AllowOverride all
    Options Indexes FollowSymLinks ExecCGI
    Order deny,allow
    Allow from all
</Directory>

And an additional directive for the vhost :

<VirtualHost *:80>
    DocumentRoot "C:\Users\pa.thiout\Desktop\projets\projet\public"
    ServerName back
</VirtualHost>

UPDATE : I decided to pull another fresh 5.7 Lumen project and just re-install composer packages and move code around. Works fine.


Solution

  • I know this topic might be a little old, but in case someone runs into this error this could be helpful.

    The problem resides on the public/index.php, It should only have:

    $app->run();
    

    I discovered this after installing a fresh lumen instalation (5.5) and replacing everything back like I had with the help of Git.. I found this huge difference on my public/index.php. Is ironic how a small piece of code can make you loose all morning.

    index.php Git Diff

    Being the left side of my previous NOT WORKING code, and the right side the code that works.