18

I just installed Lumen but when I head to its public directory localhost/lumen/public,

Sorry, the page you are looking for could not be found.

will appear.

I checked app\Http\routes.php and changed

$app->get('/', function () use ($app) {

to

$app->get('/lumen/public/', function () use ($app) {

And it worked.

But this is not the thing I want. In Laravel the '/' works perfectly. How can I make Lumen work with '/'?


BTW when I use php artisan serv, '/' works but only in artisan serv :(

Sky
  • 4,244
  • 7
  • 54
  • 83

2 Answers2

37

One Way:

In /public/index.php change

$app->run();

to

$app->run($app['request']);

Another Way:

This also works too (faster):

$app->run($app->make('request'));
Sky
  • 4,244
  • 7
  • 54
  • 83
  • 1
    Worked for me. Any particular reason why this happens? It worked well without this fix on Homestead – Remade May 29 '16 at 10:21
  • 1
    Why the second solution is too faster? First one is using prepared object, but second way is creating another object! – Khalil Laleh Sep 06 '16 at 20:00
  • Actually this didn't work for me. but instead replacing `$app->run();` with `$request = Illuminate\Http\Request::capture(); $app->run($request);` worked. But still the problem remains same. I need to have /public in my URL. any suggestions for same? – Sushank Dahiwadkar Apr 13 '18 at 05:39
  • 1
    both solutions are not working. – Kamlesh Apr 05 '19 at 08:19
0

When you aren't using php artisan serve, what are you using? If you're using vanilla php -S you need to also specify the public directory like so:

php -S localhost:8000 -t public/

You would need to do this inside of your lumen directory.

nlyn
  • 606
  • 1
  • 7
  • 20