How to Deploy a TYPO3 Project
require 'recipe/typo3.php';
Deployer is a free and open source deployment tool written in PHP. It helps you to deploy your TYPO3 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 TYPO3 consists of:
- deploy:info – Displays info about deployment
- deploy:setup – Prepares host for deploy
- deploy:lock – Locks deploy
- deploy:release – Prepares release
- typo3:update_code –
- deploy:shared – Creates symlinks for shared files and dirs
- deploy:writable – Makes writable dirs
- deploy:vendors – Installs vendors
- typo3:install:fixfolderstructure – TYPO3 - Fix folder structure
- typo3:extension:setup – TYPO3 - Set up all extensions
- typo3:language:update – TYPO3 - Update the language files of all activated extensions
- typo3:cache:flush – TYPO3 - Clear all caches
- typo3:cache:warmup – TYPO3 - Cache warmup for system caches
- deploy:publish – Publishes the release
- deploy:symlink – Creates symlink to release
- deploy:unlock – Unlocks deploy
- deploy:cleanup – Cleanup old releases
- deploy:success – Deploys your project
The typo3 recipe is based on the common recipe.
TYPO3 Deployer Recipe
Usage Examples:
Deploy to production (using Git as source): vendor/bin/dep deploy production
Deploy to staging using rsync: # In deploy.php or servers config, enable rsync set('use_rsync', true); vendor/bin/dep deploy staging
Common TYPO3 commands: vendor/bin/dep typo3:cache:flush # Clear all TYPO3 caches vendor/bin/dep typo3:cache:warmup # Warmup system caches vendor/bin/dep typo3:language:update # Update extension language files vendor/bin/dep typo3:extension:setup # Set up all extensions vendor/bin/dep typo3:install:fixfolderstructure # Automatically create required files and folders for TYPO3
Configuration
composer_config
Parse composer.json and return its contents as an array. Used for auto-detecting TYPO3 settings like public_dir and bin_dir.
return json_decode(file_get_contents('./composer.json'), true, 512, JSON_THROW_ON_ERROR);
typo3/public_dir
TYPO3 public (web) directory. Automatically determined from composer.json. Defaults to "public".
The value of this configuration is autogenerated on access.
bin/typo3
Path to the TYPO3 CLI binary. Determined from composer.json "config.bin-dir" or defaults to "vendor/bin/typo3".
The value of this configuration is autogenerated on access.
log_files
Log files to display when running ./vendor/bin/dep logs:app
'var/log/typo3_*.log'
shared_dirs
Overrides shared_dirs from recipe/deploy/shared.php.
Directories that persist between releases. Shared via symlinks from the shared/ directory.
[
'{{typo3/public_dir}}/fileadmin',
'{{typo3/public_dir}}/typo3temp/assets',
'var/lock',
'var/log',
'var/session',
'var/spool',
]
writable_dirs
Overrides writable_dirs from recipe/deploy/writable.php.
Writeable directories
[
'{{typo3/public_dir}}/fileadmin',
'{{typo3/public_dir}}/typo3temp/assets',
'var/cache',
'var/lock',
'var/log',
]
composer_options
Overrides composer_options from recipe/deploy/vendors.php.
Composer install options for production.
' --no-dev --verbose --prefer-dist --no-progress --no-interaction --optimize-autoloader'
use_rsync
If set in the config this recipe uses rsync. Default setting: false (uses the Git repository)
false
update_code_task
return get('use_rsync') ? 'rsync' : 'deploy:update_code';
rsync
[
'exclude' => array_merge(get('shared_dirs'), get('shared_files'), $exclude),
'exclude-file' => false,
'include' => ['vendor'],
'include-file' => false,
'filter' => ['dir-merge,-n /.gitignore'],
'filter-file' => false,
'filter-perdir' => false,
'flags' => 'avz',
'options' => ['delete', 'keep-dirlinks', 'links'],
'timeout' => 600,
]
typo3_updateschema_types
List of schema update types.
safe includes all necessary operations, to add or change fields or tables.
'safe'
Tasks
typo3:update_code
typo3:cache:flush
TYPO3 - Clear all caches.
TYPO3 Commands
All run via bin/php release_path/bin/typo3
typo3:cache:warmup
TYPO3 - Cache warmup for system caches.
typo3:language:update
TYPO3 - Update the language files of all activated extensions.
typo3:extension:setup
TYPO3 - Set up all extensions.
typo3:install:fixfolderstructure
TYPO3 - Fix folder structure.
deploy
Deploys a TYPO3 project.
Main deploy task for TYPO3.
- Lock deploy to avoid concurrent runs
- Create release directory
- Update code (Git or rsync)
- Symlink shared dirs/files
- Fix TYPO3 folder structure
- Ensure writable dirs
- Run extension setup & perform schema updates
- Update language files
- Install composer vendors
- Flush caches
- Warm up TYPO3 caches
- Unlock and clean up
This task is group task which contains next tasks: