Just installed Lumen and got NotFoundHttpException

15,555

Solution 1

Got it! ....

The solution is to change in public/index.php at line 28:

$app->run();

to

$app->run($app->make('request'));

No clue why, maybe you know.

Solution 2

The problem can be solved by changing the

    $app->run();

in /public/index.php to

    $request = Illuminate\Http\Request::capture();
    $app->run($request); 

Solution 3

I had the same problem today.

I was accessing it using the url http://localhost/lumen.api/public/ and I think that was the cause of the error.

To get around it, this is what I did:

First I configured a new VirtualHost entry on Xampp, located in "C:\xampp\apache\conf\extra\httpd-vhosts.conf" in my case:

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/lumen.api/public"
    ServerName lumen.api
    ServerAlias www.lumen.api
    ErrorLog "logs/lumen.api-error.log"
    CustomLog "logs/lumen.api-access.log" common
    <Directory "C:/xampp/htdocs/lumen.api/public">
        AllowOverride All
        Require all Granted
    </Directory>
</VirtualHost>

and restarted Apache on Xampp.

Then I edited my hosts file (c:\windows\system32\drivers\etc\hosts) to map a new address to my localhost.

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost   
    127.0.0.1       lumen.api

I tried again using the new URL http://lumen.api and the error was gone.

Share:
15,555

Related videos on Youtube

robertsan
Author by

robertsan

Updated on January 12, 2022

Comments

  • robertsan
    robertsan over 2 years

    I'm searching for a solution ... it's getting so frustrating. After a fresh installation of Lumen by Laravel, I simply can't access the "/" route. When I try to, it throws an error:

    NotFoundHttpException in RoutesRequests.php line 443:
    
    in RoutesRequests.php line 443
    at Application->handleDispatcherResponse(array('0')) in RoutesRequests.php line 380
    at Application->Laravel\Lumen\Concerns\{closure}() in RoutesRequests.php line 629
    at Application->sendThroughPipeline(array(), object(Closure)) in RoutesRequests.php line 382
    at Application->dispatch(null) in RoutesRequests.php line 327
    at Application->run() in index.php line 28
    
  • Nicole S.
    Nicole S. about 8 years
    This fixed a similar issue I was having while attempting to deploy a Laravel 5 application to a production environment. I would also love to know why this works.
  • Meisam Mulla
    Meisam Mulla almost 8 years
    Had the same issue with IIS 8 and lumen and this fixed it
  • AFX
    AFX almost 8 years
    Worked for me on a local MAMP......i think this is stupid. Why does this Bug/Feature occur?
  • Anand Pandey
    Anand Pandey over 6 years
    Not work for me only this line written Lumen (5.5.2) (Laravel Components 5.5.*)
  • Anurag Shrivastava
    Anurag Shrivastava about 6 years
    @AnandPandey same with me. did you get the solution