Skip to main content
Version: 8.x

How to Deploy a Contao Project

require 'recipe/contao.php';

Source

Deployer is a free and open source deployment tool written in PHP. It helps you to deploy your Contao application to a server. It is very easy to use and has a lot of features.

Three main features of Deployer are:

  • Provisioning - provision your server for you.
  • Zero downtime deployment - deploy your application without a downtime.
  • Rollbacks - rollback your application to a previous version, if something goes wrong.

Additionally, Deployer has a lot of other features, like:

  • Easy to use - Deployer is very easy to use. It has a simple and intuitive syntax.
  • Fast - Deployer is very fast. It uses parallel connections to deploy your application.
  • Secure - Deployer uses SSH to connect to your server.
  • Supports all major PHP frameworks - Deployer supports all major PHP frameworks.

You can read more about Deployer in Getting Started.

The deploy task of Contao consists of:

The contao recipe is based on the symfony recipe.

Configuration

public_path

Source

Overrides public_path from recipe/provision/website.php.

The public path is the path to be set as DocumentRoot and is defined in the composer.json of the project but defaults to public from Contao 5.0 on. This path is relative from the current_path, see recipe/provision/website.php.

Default value
$composerConfig = json_decode(file_get_contents('./composer.json'), true, 512, JSON_THROW_ON_ERROR);

return $composerConfig['extra']['public-dir'] ?? 'public';

bin/console

Source

Overrides bin/console from recipe/symfony.php.

Default value
return '{{bin/php}} {{release_or_current_path}}/vendor/bin/contao-console';

contao_version

Source

Default value
$result = run('{{bin/console}} --version');
preg_match_all('/(\d+\.?)+/', $result, $matches);
return $matches[0][0] ?? 'n/a';

symfony_version

Source

Overrides symfony_version from recipe/symfony.php.

Default value
$result = run('{{bin/console}} about');
preg_match_all('/(\d+\.?)+/', $result, $matches);
return $matches[0][0] ?? 5.0;

Tasks

contao:migrate

Source

Run Contao migrations.

This task updates the database. A database backup is saved automatically as a default.

To automatically drop the obsolete database structures, you can override the task as follows:

task('contao:migrate', function () {
run('{{bin/php}} {{bin/console}} contao:migrate --with-deletes {{console_options}}');
});

contao:manager:download

Source

Download the Contao Manager.

Downloads the contao-manager.phar.php into the public path.

contao:install:lock

Source

Lock the Contao Install Tool.

Locks the Contao install tool which is useful if you don't use it.

contao:manager:lock

Source

Lock the Contao Manager.

Locks the Contao Manager which is useful if you only need the API of the Manager rather than the UI.

contao:maintenance:enable

Source

Enable maintenance mode.

contao:maintenance:disable

Source

Disable maintenance mode.

deploy

Source

Deploy the project.

This task is group task which contains next tasks: