Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

afoysal's avatar

php artisan serve is not working

I am working on a laravel project. Project file structure is like below.

https://i.stack.imgur.com/Cmi9h.png

If I run php artisan serve then I am getting below output.

https://i.stack.imgur.com/A65Eo.png

What is the solution ?

0 likes
4 replies
chr15k's avatar

The error suggests that Laravel can't find your public directory.

You might need to specify it, for example in Providers/AppServiceProvider.php you can do something like this:

public function register()
{
    $this->app->bind('path.public', function() {
        return base_path('PATH TO PUBLIC FOLDER');
    });
}
1 like
afoysal's avatar

Thanks @chr15k . There is no public directory in this project. What is the solution to run this project ? Thanks.

chr15k's avatar

You should be able to just set the path to wherever your index.php file is located using the above.

php artisan serve should then use this directory to serve your application.

For example, if my directory is public_html:

app/Providers/AppServiceProvider.php

public function register()
{
    $this->app->bind('path.public', function() {
        return base_path('public_html');
    });
}

I think you will also want to update server.php in this case:

server.php

<?php

/**
 * Laravel - A PHP Framework For Web Artisans
 *
 * @package  Laravel
 * @author   Taylor Otwell <[email protected]>
 */

$uri = urldecode(
    parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);

// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public_html'.$uri)) {
    return false;
}

require_once __DIR__.'/public_html/index.php';

After the changes, re-run php artisan serve

1 like

Please or to participate in this conversation.