10.1 Deploy Using Composer

When you want to deploy. On your server run:

composer install \
--no-progress \
--prefer-dist \
--no-dev \
--optimize-autoloader \

install: Downloads the same versions of all the dependacies defined in the composer.lock file.

--no-progress: don't output progress as the bash script runs

--prefer-dist: Download distribution packages, use local cache

--no-dev: Avoids downlodaing development libraries (You don't need devel module on your production site...)

--optimize-autoloader: Generate class map for PRS-0/4 autoloaders

10.2 Using a service

Example: Using Deployer a deployment tool for PHP projects

Reqire it in your project

composer require deployer/deployer

Creae a deploy.php file in your repo

namespace Deployer;
 
require 'recipe/drupal8.php';
 
set('repository', 'https://github.com/YOUR-REPO-HERE');
 
server('drupal8day', 'drupal8day.dev')
      ->user('drupal')
    ->forwardAgent()
    ->set('deploy_path', 'var/www/html/drupal')
    ->stage('develop');
 
after('deploy', 'deploy:vendors');

This file defines everything necessary for the tool to build the site starting with requiring the recipe we began the tutorial with and adding all dependancies, etc. to the github repo.

This is where the script calls Drupal Console:

after('deploy', 'deploy:vendors');

The deploy:vendors call runs composer install on the server with all the appropriate flags...

To run this deploy.php file:

deployer deploy deveop