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

marcorieser's avatar

Override application root path for cli

I am running a laravel app on a shared hoster. When calling app()->path() I get /home/httpd/vhosts/firefly.ch/statamic-firefly/app which is correct. When running the same in cli tinker I get /statamic/firefly/app which is wrong and because of that artisan optimize generates the wrong paths in the cache. I guess the issue is that my entrypoint via ssh is /home/httpd/vhosts/firefly.ch which makes this my root directory and causes the wrong path. I contacted the hosting provider and asked if they could change my ssh config to start at /. The response was "For most frameworks/systems it's possible to adjust the path the cli uses." Googled for that but did't find a config parameter. Any suggestions?

0 likes
5 replies
jlrdw's avatar

I don't know your entire folder structure. But when laravel is setup to point to public as the documents root all works correctly.

Public can be renamed however. But see this, but search other past answers as well:

https://laracasts.com/discuss/channels/laravel/deployed-laravel-to-hosting-all-my-directoriesfiles-are-accessible?page=1&replyId=645918

and

https://laracasts.com/discuss/channels/general-discussion/site-also-accessible-from-public?page=1&replyId=715883

marcorieser's avatar

It's a Statamic installation which uses the default Laravel config. The document root is pointing to /public and in the browser everything is running perfectly. The only thing is that the cli gets the wrong absolute path to my application.

marcorieser's avatar

@jlrdw Why should it work in production when there is a different server config than in development?

I tried to set $app->setBasePath('/home/httpd/vhosts/firefly.ch/statamic-firefly'); in bootstrap/app.php which was what I was searching for but the problem now is that the cli can not access the directory. Seems like this has to be fixed by the hosting provider.

marcorieser's avatar
marcorieser
OP
Best Answer
Level 17

So the solution was the above plus creating the desired folder structure with symlinks pointing to /.

Please or to participate in this conversation.