Framework: Config:cache for default Laravel configuration creates absolute paths

Created on 12 Feb 2016  ·  3Comments  ·  Source: laravel/framework

I noticed that when I run php artisan config:cache the resulting cache has absolute paths because by default there are some storage_path() calls in Laravel config files.

I have read the documentation:

You should typically run the php artisan config:cache command as part of your production deployment routine.

The documentation does not say that I should run the command on the server and not on my automated CI build agent. But not everyone has access to php artisan config:cache command on their servers for executing it remotely from CI build agent.

I think the documentation should be updated to reflect the requirement to run the command on the server.
However, it would be even better to implement some way to generate config cache with relative paths.

Currently I could add a workaround for the issue and create a PHP controller which executes artisan command, and call it during deployment. But the problem is that on our server deployment is set up to work through Git push and only after a few minutes the web site gets synced with current version in the repository. I don't think it would be a good idea to just sit inside my CI deploy script and wait for unknown time just to be able to call URL to my custom controller which in turn executes php artisan config:cache.

So, we are back to the question - how to make the paths in config files relative to the app root and generate cached config which will work with relative paths?

Most helpful comment

In the Laravel docs quote I mentioned above, "deployment routine" does not explicitly mean that the cache command has to be run on the server and not in the folder which is about to be deployed. Therefore I think it is worth to expand this sentence, so people do not make false assumptions (as I did).

Anyway, it's a shame that we cannot use relative paths instead of storage_path() in config files. This would make things much easier for automatic CI deployments.

All 3 comments

You need to run composer and our optimization commands on your server, not before deployment.

In the Laravel docs quote I mentioned above, "deployment routine" does not explicitly mean that the cache command has to be run on the server and not in the folder which is about to be deployed. Therefore I think it is worth to expand this sentence, so people do not make false assumptions (as I did).

Anyway, it's a shame that we cannot use relative paths instead of storage_path() in config files. This would make things much easier for automatic CI deployments.

Yes, that's why documentation says "deployment routine", not "build routine"...

Was this page helpful?
0 / 5 - 0 ratings