lumendev lumendev - 1 month ago 37
Apache Configuration Question

Lumen gives NotFoundHttpException in RoutesRequests.php without public/index.php

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


Answer

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

$app->get('request', function() {
return view('your view file');
});