How to Configure PHP Deployer in TYPO3?

Do you want to use most popular PHP Deployer in TYPO3 project? Follow these guide to Install Deployer, Configure Hosts, TYPO3 PHP Deployer code.

Step 1. Install PHP Deployer

// Download latest PHP Deployer
curl -LO https://deployer.org/deployer.phar

// Switch to root user + Move to bin to access "dep" command
sudo -s
mv deployer.phar /usr/local/bin/dep
chmod +x /usr/local/bin/dep

// Verify the installation
dep --version

Step 2. Configure PHP Deployer Hosts.yml

# Create .hosts.yaml at root of your project

# Configure Staging Server
DOMAIN/IP:
  host: DOMAIN/IP
  user: username
  stage: staging
  branch: staging
  identity_file: ~
  deploy_path: /var/www/your/path/

# Configure Production Server
DOMAIN/IP:
  host: DOMAIN/IP
  user: username
  stage: production
  branch: master
  identity_file: ~
  deploy_path: /var/www/your/path/

Step 3. Prepare TYPO3 Deploy.php

<?php

// Create deploy.php at root of your project

namespace Deployer;
require 'recipe/common.php';

# Project name
set('application', 'project');

# Define Git-Repository
set('repository', '[email protected]:yourpath/project.git');

# [Optional] Allocate tty for git clone. Default value is false.
set('git_tty', true); 

# Set maxium releases backup
set('keep_releases', 5);

# Set Server
inventory('.hosts.yaml');

# DocumentRoot / WebRoot for the TYPO3 installation
set('typo3_webroot', 'public');

# Main TYPO3 task
task('deploy', [
    'deploy:info',
    'deploy:prepare',
    'deploy:lock',
    'deploy:release',
    'deploy:update_code',
    'deploy:shared',
    'deploy:vendors',
    'deploy:writable',
    'deploy:symlink',
    'deploy:unlock',
    'cleanup',
])->desc('Deploy your project');
after('deploy', 'success');

# Shared directories
set('shared_dirs', [
    '{{typo3_webroot}}/fileadmin',
    '{{typo3_webroot}}/typo3temp',
    '{{typo3_webroot}}/uploads'
]);

# Shared files
set('shared_files', [
    '{{typo3_webroot}}/.htaccess'
]);

# Writeable directories
set('writable_dirs', [
    'config',
    '{{typo3_webroot}}/fileadmin',
    '{{typo3_webroot}}/typo3temp',
    '{{typo3_webroot}}/typo3conf',
    '{{typo3_webroot}}/uploads'
]);

# [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');

Step 4. Done! Go ahead to deploy.

 

dep deploy

Post a Comment

×

Got answer to the question you were looking for?