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

Botv0091's avatar

How to change location of index.php for local development?

Hello.

For some reasons i need to relocate all stuff from project/public folder to project folder aka root folder. I made some changes in index.php and on shared server everything works. But when I work on a local PC I get an error:

WARN  PHP Fatal error: Uncaught Error: Failed opening required 'public/index.php' (include_path='.:/usr/share/php') in vendor/laravel/framework/src/Illuminate/Foundation/resources/server.php:16.

I understand the meaning of this particular error and understand that sail incorrectly sees the folder in which it is stored index.php . How do I reconfigure sail so that it sees the paths correctly from root, not from public?

Thanks.

0 likes
6 replies
jlrdw's avatar

That will make your application insecure I highly suggest setting up laravel correctly.

You point to public as document root.

Botv0091's avatar

@jlrdw Yes, i understand, but for now i hove no choice, by the way - im curious how it work

Tray2's avatar

@Botv0091 If you are using apache as your server you can reroute all requests to the /public directory instead. Just make sure that your .env isn't accessible.

Lumethys's avatar

@Botv0091 but you are in local, how you get your code running doesnt affect anyone

Im working on a project with docker, but somehow the docker server is very slow on my machine, so i just do php artisan serve and work like normal

Please or to participate in this conversation.