Scalingo / documentation

Scalingo Documentation Center
https://doc.scalingo.com
9 stars 73 forks source link

fix: How to run `php artisan optimize` using postdeploy hook #2876

Closed sc-zenokerr closed 6 days ago

sc-zenokerr commented 1 week ago

Add instructions to laravel page

Fixes issue #2843

sc-zenokerr commented 1 week ago

I think it will have an effect, because as far as I understand it, php reads the files every request. It will read the cache if it is there. What do you think?

sc-zenokerr commented 1 week ago

Actually it looks like php artisan optimize is actually deprecated since v5.5. to be removed in v5.6... however the command still exists in v11.. so wierd

aurelien-reeves-scalingo commented 1 week ago

I think it will have an effect, because as far as I understand it, php reads the files every request. It will read the cache if it is there. What do you think?

this is not how postdeploy hook are working it is not the right place to run php artisan optimize

php artisan optimize seems to generate some cache on the filesystem. postdeploy hook has no impact on the app container filesystem.

the command has to be run at build time, or at runtime before we actually start the app server. There is no place that I know to run it at build time, so it has to be run at runtime

postdeploy is neither build time or app runtime. It is a hook that is run after the build, alongside the runtime of the app. It is run as part of a one-off container after it has been built. And as you know: anything that is done on a one-off filesystem is not reproduced on any other container, running or to be run

sc-zenokerr commented 1 week ago

Of course, it won't modify the filesystem of the running app. The latest push takes into account your comments.