Installation
composer require dbh/easy-deploy-bundle
Add the bundle to config/bundles.php:
return [
// ...
Dbh\EasyDeployBundle\DbhEasyDeployBundle::class => ['all' => true],
];
Configure SSH
Ensure SSH access is set up for your remote servers (see Local SSH Config Tutorial). Example ~/.ssh/config:
Host staging
HostName your-server.com
User deploy
IdentityFile ~/.ssh/id_rsa
First Deployment Run the default deployer via CLI:
php bin/console easy-deploy:deploy staging
This triggers a zero-downtime deploy to the staging server.
DefaultDeployer) for basic workflows (clone, symlink, restart services).easy_deploy.yaml config (auto-generated in config/packages/dbh_easy_deploy.yaml) matches your server’s paths (e.g., deploy_path, release_path).Multi-Stage Deployments
Define stages in config/packages/dbh_easy_deploy.yaml:
dbh_easy_deploy:
servers:
staging:
host: staging
deploy_path: /var/www/staging
production:
host: production
deploy_path: /var/www/prod
Deploy to multiple stages sequentially:
php bin/console easy-deploy:deploy staging production
Custom Deployer Integration
Extend DefaultDeployer for project-specific logic (e.g., database migrations, asset compilation):
// src/Deployer/CustomDeployer.php
namespace App\Deployer;
use Dbh\EasyDeployBundle\Deployer\AbstractDeployer;
class CustomDeployer extends AbstractDeployer {
protected function deploy(): void {
$this->run('php bin/console doctrine:migrations:migrate --no-interaction');
parent::deploy();
}
}
Register in config/packages/dbh_easy_deploy.yaml:
dbh_easy_deploy:
deployer: App\Deployer\CustomDeployer
Git Hooks & Pre/Post Actions
Use pre_deploy and post_deploy hooks in the config:
dbh_easy_deploy:
servers:
staging:
pre_deploy: ['php bin/console cache:clear']
post_deploy: ['systemctl restart php-fpm']
composer install.deploy_vars in the config:
servers:
production:
deploy_vars:
APP_ENV: prod
DATABASE_URL: "mysql://user:pass@localhost/db"
deploy_path pointing to a bind-mounted volume for shared storage.SSH Key Permissions
~/.ssh/id_rsa has 600 permissions (chmod 600 ~/.ssh/id_rsa).ssh -vT staging
File Ownership
deploy_path must be writable by the SSH user (e.g., chown -R deploy:deploy /var/www/staging).Git Shallow Clone
--depth 1 by default. Disable with:
dbh_easy_deploy:
git_depth: false
Symlink Conflicts
symlinks config:
symlinks:
- { from: '{{ release_path }}/var/log', to: '{{ deploy_path }}/var/log' }
php bin/console easy-deploy:deploy staging --verbose
php bin/console easy-deploy:deploy staging --dry-run
AbstractDeployer::log() for project-specific logging.Custom Commands
Add new commands by extending AbstractDeployer and registering them in services.yaml:
services:
App\Deployer\CustomCommand:
tags: ['console.command']
arguments: ['@dbh_easy_deploy.deployer']
Remote Script Execution
Use run() in custom deployers to execute arbitrary commands:
$this->run('composer install --optimize-autoloader --no-dev');
Post-Deploy Validation
Implement postDeploy() to validate the release (e.g., check file integrity):
protected function postDeploy(): void {
$this->assertFileExists('{{ release_path }}/vendor/autoload.php');
}
{{ release_path }}) for dynamic paths in symlinks or deploy_vars.easy_deploy.yaml with sensible defaults. Override only what’s necessary.How can I help you explore Laravel packages today?