# How to Deploy a Contao Project ```php require 'recipe/contao.php'; ``` [Source](/recipe/contao.php) 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](/docs/getting-started.md). The [deploy](#deploy) task of **Contao** consists of: * [deploy:prepare](/docs/recipe/common.md#deployprepare) – Prepares a new release * [deploy:info](/docs/recipe/deploy/info.md#deployinfo) – Displays info about deployment * [deploy:setup](/docs/recipe/deploy/setup.md#deploysetup) – Prepares host for deploy * [deploy:lock](/docs/recipe/deploy/lock.md#deploylock) – Locks deploy * [deploy:release](/docs/recipe/deploy/release.md#deployrelease) – Prepares release * [deploy:update_code](/docs/recipe/shopware.md#deployupdate_code) – * [deploy:shared](/docs/recipe/deploy/shared.md#deployshared) – Creates symlinks for shared files and dirs * [deploy:writable](/docs/recipe/deploy/writable.md#deploywritable) – Makes writable dirs * [deploy:vendors](/docs/recipe/deploy/vendors.md#deployvendors) – Installs vendors * [contao:maintenance:enable](/docs/recipe/contao.md#contaomaintenanceenable) – Enable maintenance mode * [contao:migrate](/docs/recipe/contao.md#contaomigrate) – Run Contao migrations * [contao:maintenance:disable](/docs/recipe/contao.md#contaomaintenancedisable) – Disable maintenance mode * [deploy:publish](/docs/recipe/common.md#deploypublish) – Publishes the release * [deploy:symlink](/docs/recipe/deploy/symlink.md#deploysymlink) – Creates symlink to release * [deploy:unlock](/docs/recipe/deploy/lock.md#deployunlock) – Unlocks deploy * [deploy:cleanup](/docs/recipe/deploy/cleanup.md#deploycleanup) – Cleanup old releases * [deploy:success](/docs/recipe/common.md#deploysuccess) – The contao recipe is based on the [symfony](/docs/recipe/symfony.md) recipe. ## Configuration ### public_path [Source](https://github.com/deployphp/deployer/blob/master/recipe/contao.php#L11) Overrides [public_path](/docs/recipe/provision/website.md#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](/docs/recipe/common.md#current_path), see [`recipe/provision/website.php`](/docs/recipe/provision/website.php#public_path). ```php title="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](https://github.com/deployphp/deployer/blob/master/recipe/contao.php#L29) Overrides [bin/console](/docs/recipe/symfony.md#bin/console) from `recipe/symfony.php`. ```php title="Default value" return '{{bin/php}} {{release_or_current_path}}/vendor/bin/contao-console'; ``` ### contao_version [Source](https://github.com/deployphp/deployer/blob/master/recipe/contao.php#L33) ```php title="Default value" $result = run('{{bin/console}} --version'); preg_match_all('/(\d+\.?)+/', $result, $matches); return $matches[0][0] ?? 'n/a'; ``` ### symfony_version [Source](https://github.com/deployphp/deployer/blob/master/recipe/contao.php#L39) Overrides [symfony_version](/docs/recipe/symfony.md#symfony_version) from `recipe/symfony.php`. ```php title="Default value" $result = run('{{bin/console}} about'); preg_match_all('/(\d+\.?)+/', $result, $matches); return $matches[0][0] ?? 5.0; ``` ## Tasks ### contao:migrate [Source](https://github.com/deployphp/deployer/blob/master/recipe/contao.php#L55) 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 [Source](https://github.com/deployphp/deployer/blob/master/recipe/contao.php#L61) Download the Contao Manager. Downloads the `contao-manager.phar.php` into the public path. ### contao:install:lock [Source](https://github.com/deployphp/deployer/blob/master/recipe/contao.php#L67) Lock the Contao Install Tool. Locks the Contao install tool which is useful if you don't use it. ### contao:manager:lock [Source](https://github.com/deployphp/deployer/blob/master/recipe/contao.php#L73) 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](https://github.com/deployphp/deployer/blob/master/recipe/contao.php#L79) Enable maintenance mode. ### contao:maintenance:disable [Source](https://github.com/deployphp/deployer/blob/master/recipe/contao.php#L94) Disable maintenance mode. ### deploy [Source](https://github.com/deployphp/deployer/blob/master/recipe/contao.php#L106) Deploy the project. This task is group task which contains next tasks: * [deploy:prepare](/docs/recipe/common.md#deployprepare) * [deploy:vendors](/docs/recipe/deploy/vendors.md#deployvendors) * [contao:maintenance:enable](/docs/recipe/contao.md#contaomaintenanceenable) * [contao:migrate](/docs/recipe/contao.md#contaomigrate) * [contao:maintenance:disable](/docs/recipe/contao.md#contaomaintenancedisable) * [deploy:publish](/docs/recipe/common.md#deploypublish)