standev
standev

Reputation: 21

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

Upvotes: 1

Views: 2935

Answers (2)

theQuizProject
theQuizProject

Reputation: 59

The problem was solved by changing the

$app->run();

in /public/index.php to

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

Upvotes: 2

Sachith Muhandiram
Sachith Muhandiram

Reputation: 2972

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

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

Upvotes: 0

Related Questions