Alexander Schranz
Core Developer – Sulu GmbH
Core developer and support king. So dedicated to his work that we couldn't find a hobby to mention.

Deploy Sulu with Deployer

Deployer is a well known deployment tool for PHP applications and we are happy to announce that the new version of Deployer is shipped with recipes for Sulu. Once configured, it's easy to deploy your application on one or multiple webservers.

Installation of Deployer

To use Deployer we first need to install it as dependency over composer.

composer require deployer/deployer --dev
Installation of Deployer

Configure Deployer

To configure the deployment you need to create a deploy.php in your application.

Since version 6.4, Deployer is shipped with two recipes for Sulu. One for Sulu 1.x, based on the sulu-minimal repository, and Symfony 3 and one for Sulu 2.x, based on Symfony 4. In the following example we will use the newer Sulu 2.x recipe as the basic configuration.


namespace Deployer;

require 'vendor/deployer/deployer/recipe/sulu2.php';

    ->set('deploy_path', '/var/website/')
    ->set('branch', function () {
        return input()->getOption('branch') ?: 'master';
    ->set('http_user', 'www-data')
    ->set('http_group', 'www-data')

// Configuration
set('repository', '');

set('composer_options', '{{composer_action}} --verbose --prefer-dist --no-progress --no-interaction --no-dev --optimize-autoloader --apcu-autoloader');

// Optional Scripts when using migrations:
// before('deploy:symlink', 'database:migrate');
// before('deploy:symlink', 'phpcr:migrate');

// if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');
Configure Deployer

Deploy the application

To deploy your application you just need to run the following command:

vendor/bin/dep deploy prod
Deploy the application

When you deploy for the first time, create your VHost based on the webserver you use. As Deployer uses symlinks, the webserver should be allowed to follow symlinks and the VHost should always point the the current directory of the deployed application.

Deployer has many configuration options for connections, permissions etc. and recipes which can be found in the documentation.

There are also some additional recipes in the deployer/recipes repository, e.g. one to clear opcache.

Once Deployer is configured correctly for your server, you can easily deploy your Sulu website or application using continous deployment over continous integration server.

Give it a try and let us know if the Deployer recipes for Sulu works correctly for you.