Back to Deployer

How to Deploy a Contao Project

docs/recipe/contao.md

8.0.36.6 KB
Original Source
<!-- DO NOT EDIT THIS FILE! --> <!-- Instead edit recipe/contao.php --> <!-- Then run bin/docgen -->

How to Deploy a Contao Project

php
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.

php
$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.

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

contao_version

Source

php
$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.

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

Tasks

contao:migrate {#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:

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

contao:manager:download {#contao-manager-download}

Source

Download the Contao Manager.

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

contao:install:lock {#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 {#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 {#contao-maintenance-enable}

Source

Enable maintenance mode.

contao:maintenance:disable {#contao-maintenance-disable}

Source

Disable maintenance mode.

deploy {#deploy}

Source

Deploy the project.

This task is group task which contains next tasks: