Installation:
composer require aritti/easy-deploy-bundle
Add the bundle to config/bundles.php:
return [
// ...
Aritti\EasyDeployBundle\EasyDeployBundle::class => ['all' => true],
];
Configure a Deployer:
Create a deployer class (e.g., config/deploy.php) extending DefaultDeployer or CustomDeployer:
use EasyCorp\Bundle\EasyDeployBundle\Deployer\DefaultDeployer;
return new class extends DefaultDeployer {
public function configure() {
return $this->getConfigBuilder()
->server('user@hostname', '/path/to/deploy/dir')
->repository('git@github.com:user/repo.git')
;
}
};
First Deployment: Run the deploy command:
php bin/console easy-deploy:deploy
Use the default deployer for a standard Symfony app with:
Example workflow:
# Warm up cache locally
php bin/console cache:warmup
# Deploy
php bin/console easy-deploy:deploy
# Verify
php bin/console easy-deploy:verify
Standard Deployment Cycle:
# Pre-deploy checks
php bin/console easy-deploy:check
# Deploy
php bin/console easy-deploy:deploy
# Post-deploy verification
php bin/console easy-deploy:verify
Rollback:
php bin/console easy-deploy:rollback
Multi-Server Deployment:
return new class extends DefaultDeployer {
public function configure() {
return $this->getConfigBuilder()
->server('user@web1.example.com', '/var/www/app')
->server('user@web2.example.com', '/var/www/app')
->repository('git@github.com:user/repo.git')
;
}
};
CI/CD Pipeline Integration:
# Example GitHub Actions workflow
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
- run: composer install
- run: php bin/console easy-deploy:deploy
Custom Hooks: Extend deployer to add pre/post hooks:
public function beforeStartingDeploy() {
$this->runLocal('composer install --no-dev --optimize-autoloader');
}
public function afterFinishingDeploy() {
$this->runRemote('sudo systemctl restart php-fpm');
}
Environment-Specific Deployers:
// config/deploy/production.php
return new class extends DefaultDeployer {
public function configure() {
return $this->getConfigBuilder()
->server('prod@example.com', '/var/www/prod')
->repository('git@github.com:user/repo.git')
->useSshAgentForwarding(true)
;
}
};
Database Migrations:
public function deploy() {
$this->runRemote('php bin/console doctrine:migrations:migrate --no-interaction');
parent::deploy();
}
SSH Agent Forwarding Issues:
ssh -T git@github.com on both local and remote servers~/.ssh/config for ForwardAgent no settingsPermission Problems:
chown -R user:group /path/to/deploy/dirGit Authentication Failures:
deployKey config option~/.ssh/known_hosts has the server's fingerprintComposer Cache Issues:
public function beforeStartingDeploy() {
$this->runRemote('rm -rf vendor composer.lock');
}
Verbose Mode:
php bin/console easy-deploy:deploy --verbose
Dry Run:
php bin/console easy-deploy:deploy --dry-run
SSH Debugging:
ssh -vvv user@host # Test SSH connection manually
Server Configuration:
Repository Handling:
->repository('git@github.com:user/repo.git', ['--recurse-submodules'])
Environment Variables:
->environment(['APP_ENV=prod', 'APP_DEBUG=0'])
Custom Commands:
Create console commands extending EasyDeployCommand:
use EasyCorp\Bundle\EasyDeployBundle\Command\EasyDeployCommand;
class CustomDeployCommand extends EasyDeployCommand {
protected function configure() {
$this->setName('app:custom-deploy');
}
protected function execute(InputInterface $input, OutputInterface $output) {
// Custom logic
}
}
Event Listeners:
use EasyCorp\Bundle\EasyDeployBundle\Event\DeployEvent;
class MyDeployListener {
public function onDeploy(DeployEvent $event) {
// Pre/post deploy logic
}
}
Custom Deployer Methods: Override core methods:
public function updateCode() {
$this->runRemote('git clone --depth 1 git@github.com:user/repo.git /tmp/repo');
$this->runRemote('rsync -avz /tmp/repo/ /var/www/app/');
}
Use Rsync:
public function deploy() {
$this->runLocal('rsync -avz --delete ./ user@host:/var/www/app/');
}
Shallow Clone:
->repository('git@github.com:user/repo.git', ['--depth=1'])
Parallel Deployments:
->server('user@web1.example.com', '/var/www/app')
->server('user@web2.example.com', '/var/www/app')
// Runs in parallel by default
How can I help you explore Laravel packages today?