Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sc-zenokerr
Copy link
Contributor

Add instructions to laravel page

Fixes issue #2843

Copy link
Contributor

@aurelien-reeves-scalingo aurelien-reeves-scalingo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The optimize command requires to be run before app start-up

It won't have any effect on the app start-up when ran in a postdeploy hook

@sc-zenokerr
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor

aurelien-reeves-scalingo commented Nov 15, 2024

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
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants