Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dtunes's avatar

Envoyer "cache" vendor and node_modules to {{project}} path an acceptable practice?

Hi all,

I'm setting up a couple of deployment sites with https://envoyer.io, just checking if anyone is doing anything similar, or if you have any downsides or a better way to do the following, any feedback is much appreciated.

before composer install

# cache:vendor
cd {{ release }}

VENDOR_HASH=`md5sum composer.lock | awk '{ print $1 }'`

if [ ! -d {{ project }}/vendor ]
then
    mkdir -p {{ project }}/vendor
fi

if [ -e {{ project }}/composer.lock ]
then
    md5sum -c <<<"$VENDOR_HASH {{ project }}/composer.lock"
    
    if [ $? = 0 ]
    then
        ln -s {{ project }}/vendor
    else
        cp composer.lock {{ project }}
    fi
else
    cp composer.lock {{ project }}
fi

before composer install

# cache:node_modules

cd {{ release }}

YARN_HASH=`md5sum yarn.lock | awk '{ print $1 }'`

if [ ! -d {{ project }}/node_modules ]
then
    mkdir -p {{ project }}/node_modules
fi

if [ -e {{ project }}/yarn.lock ]
then
    md5sum -c <<<"$YARN_HASH {{ project }}/yarn.lock"
    
    if [ $? = 0 ]
    then
        ln -s {{ project }}/node_modules
    else
        cp yarn.lock {{ project }}
    fi
else
    cp yarn.lock {{ project }}
fi

In case you're wondering, I do have a couple of hooks after composer installs, "yarn" and "yarn build".

Cheers

0 likes
2 replies
dtunes's avatar

I think I just identified one obvious issue, will cp the node_modules and vendor into the {{ release }} folder instead so they're isolated

dtunes's avatar

In the end, decided not to pursue this, both composer and yarn/npm have good caching.

Please or to participate in this conversation.