How to deploy correctly when using Composer's develop / production switch?

后端 未结 5 1766
深忆病人
深忆病人 2020-12-02 03:19

Composer has the option to load several dependencies only while being in development, so the tools will not be installed in production (on the live server). This is (in theo

5条回答
  •  一整个雨季
    2020-12-02 04:16

    On production servers I rename vendor to vendor-, and during deployment will have two vendor dirs.

    A HTTP cookie causes my system to choose the new vendor autoload.php, and after testing I do a fully atomic/instant switch between them to disable the old vendor dir for all future requests, then I delete the previous dir a few days later.

    This avoids any problem caused by filesystem caches I'm using in apache/php, and also allows any active PHP code to continue using the previous vendor dir.


    Despite other answers recommending against it, I personally run composer install on the server, since this is faster than rsync from my staging area (a VM on my laptop).

    I use --no-dev --no-scripts --optimize-autoloader. You should read the docs for each one to check if this is appropriate on your environment.

提交回复
热议问题