you could put the site into maintenance mode for a few seconds
or, what I do is replicate into a new folder, run composer install and then flip a symlink to point the webserver to the new folder
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I deploy my code to production via rsync:
-a --delete --delay-updates
For this process I also ignore the vendor folder (plus the .env file and stuff like that). I sync composer.json as well as composer.lock. --delay-updates are added for better atomicity.
Then I run the following command on my server to make sure that the Composer packages are on par with my dev setup:
composer install --no-dev --optimize-autoloader --apcu-autoloader
Somewhere in this process a problem occurs. If any request hits the server or a command is executed during the deployment, Laravel fails to load due to missing service providers.
Before that, I never had any errors during deployment but I also deployed everything - including the vendor folder and dev-packages which means that I also didn't run Composer server side. I've tried mitigating this problem by adding both --optimize-autoloader and the --apcu-autoloader (APCu is indeed installed on the server) options to the Composer command.
I'm tempted to go back to the earlier setup but that means I will deploy the dev-packages as well.
Any input is greatly appreciated.
Hmm, so. I tinkered with the above solution but it presented a lot of new problems. One example is the storage folder on the server which needs to be maintained across deployments.
Another problem is the fact that I don't deploy files that are currently not committed (AKA. files that are work-in-progress). - Obviously the older version of the files still needs to be present on the server.
However, I found a rather simple workaround. I just "deploy" my project locally by running this on my development machine prior to executing my rsync command:
composer install --no-dev --optimize-autoloader
When the sync is done, I revert back to the dev environment by running this:
composer install
Please or to participate in this conversation.