1

The Lumen installation in my server is giving NotFoundHttpException when accessing without public/index.php.

Apache config:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/myapi/public

    <Directory /var/www/html/myapi>
            AllowOverride All
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

.htaccess:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Directory structure:

> var/www/html
> ------------/myapi/ (lumen application)
> ------------/myapi/public/

index.php in var/www/html/myapi/public

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

NotFoundHttpException:

  1. in RoutesRequests.php line 461
  2. at Application->handleDispatcherResponse(array('0')) in RoutesRequests.php line 398
  3. at Application->Laravel\Lumen\Concerns{closure}() in RoutesRequests.php line 650
  4. at Application->sendThroughPipeline(array(), object(Closure)) in RoutesRequests.php line 400
  5. at Application->dispatch(object(Request)) in RoutesRequests.php line 341
  6. at Application->run(object(Request)) in index.php line 30
David Makogon
  • 69,407
  • 21
  • 141
  • 189
standev
  • 21
  • 1
  • 5

2 Answers2

2

The problem was solved by changing the

$app->run();

in /public/index.php to

$request = Illuminate\Http\Request::capture();
$app->run($request);
MilanPanchal
  • 2,943
  • 1
  • 19
  • 37
0

NotFoundHttpException is given when your request is not listed in route.php

$app->get('request', function() {
return view('your view file');
});
Sachith Muhandiram
  • 2,819
  • 10
  • 45
  • 94
  • I do have the request listed in /var/www/html/myapi/routes/web.php in lumen 5.3. \n `$app->get('/hello', function () use ($app) { return "Hello Universe";` }); – standev Nov 06 '16 at 13:21
  • 1
    not `web.php`...`route.php` is located inside **app/html** folder. – Sachith Muhandiram Nov 06 '16 at 21:54
  • Thanks for your response Sachith. Lumen 5.3 seems to have removed the route.php and replaced with web.php in the 'routes' folder. – standev Nov 07 '16 at 10:59