ideas
ideas copied to clipboard
Changeable public directory name
/app
/bootstrap
/database
.
/public_html <-- refactored from /public
/resources
.
easiest usage for shared hostings.we change the directory name in .env like APP_PUBLIC_DIR=public_html
Wouldn't a symbolic link work for the shared hosting scenarios you mentioned?
Some providers prevent the creation of symbolic links but a good solution and a public:link command like storage:link can be added.
You can do this by overriding the path.public instance in the container. You will probably need to register it in bootstrap/app.php or a bootstrapper that's called by the kernel (check the Kernel.php files provided by laravel for more info).
$app->instance('path.public', base_path('public_html'));
❯ php artisan tinker
Psy Shell v0.10.4 (PHP 7.4.13 — cli) by Justin Hileman
>>> public_path()
=> "/Users/matt/code/laravel/public_html"
yes i know but the shortcut would be nice and it would increase portability
You can do this by overriding the
path.publicinstance in the container
Even that's not good enough, am I right? Other core files still need to be changed:
<public folder>/index.phpneeds to be edited torequire()the right paths<project root>/server.phpneeds to be edited torequire()the right paths
What's more, some projects might want different configurations for local dev vs. test/live deployment:
- On local dev computer developers might prefer the original Laravel application layout, with the original index.php & server.php PHP
require()s - Only on web deployment is it needed to be in altered public folder layout with altered index.php/server.php PHP
require()paths
It would be great if this can be adjusted from .env (though how? this alteration is so early in the boot process dotenv isn't even loaded..) perhaps indeed a command similar to storage:link