Pierre de LESPINAY
Pierre de LESPINAY

Reputation: 46158

Deploy the vendors without Composer

I usually deploy my vendors with a simple composer install in production.

I would prefer not using composer in production, so I'd need to build the vendors from my machine and deploy them in production.

I could copy the vendor directory but I'll certainly have to install other files like app/bootstrap.cache.php or other autoloader.php

2 questions so:

Upvotes: 3

Views: 1890

Answers (1)

Sven
Sven

Reputation: 70853

I would say the procedure is pretty straighforward (at least it works for me that way): To deploy your application, you'd create a new directory, export the code from a tag into it (i.e. you don't export all repository-managing data like a .git directory). You then run composer install --no-dev, which will do some work, and should also run anything that is mentioned in the scripts in the composer.json file.

The result in this previously empty directory goes to the production server in whatever way you like, be it SCP, SFTP, rsync... There is no real "magic" going on here, essentially it is copying of files.

You may want to make sure you can roll back quickly, so I'd recommend to deploy every version into a designated directory, and then link the current version with a symlink. As an example: You had deployed your old version in /srv/www/htdocs/app-1.0 and symlinked the directory /srv/www/htdocs/app to point to this directory. The vhost uses the generic app directory to serve the app.

The deployment will create a new directory /srv/www/htdocs/app-1.1, and putting it live will simply delete the old symlink and create a new one to the new directory. This should put your new version live instantly. Rolling back would mean to delete the symlink and create the one pointing to the old version again.

YMMV, because things like caches will affect the outcome, but this is not in the scope of how and where to use Composer to deploy software.

Upvotes: 5

Related Questions