Installation:
composer require disparity/deployment-bundle:>=0.1
Add the bundle to AppKernel.php (Symfony 2.x):
new Disparity\DeploymentBundle\DisparityDeploymentBundle(),
First Use Case: Migrate to a specific commit/tag/branch:
php app/console disparity:deployment:migrate v1.0.0
display-sql flag for debugging migrations.php app/console help disparity:deployment:migrateapp/config/config.yml for bundle-specific settings (if any).Deployment Migration:
main, v2.3.1, abc1234).--display-sql: Log SQL queries (useful for debugging Doctrine migrations).--clean-working-copy: Reset working directory before migration (caution: destructive).php app/console disparity:deployment:migrate feature/xyz --clean-working-copy
Integration with Laravel (Symfony Bridge):
Process component to call the command from Laravel:
use Symfony\Component\Process\Process;
$process = new Process(['php', 'artisan', 'disparity:deployment:migrate', 'v1.2.0']);
$process->run();
echo $process->getOutput();
Post-Migration Hooks:
MigrateCommand (if source is available) to trigger Laravel events (e.g., Deployed).// app/Console/Commands/Deploy.php
use Disparity\DeploymentBundle\Command\MigrateCommand;
class Deploy extends MigrateCommand {
protected function execute(InputInterface $input, OutputInterface $output) {
parent::execute($input, $output);
event(new DeploymentCompleted($this->getTarget()));
}
}
Dependency Management:
composer.json updates post-migration.--clean-working-copy.--display-sql to validate migrations without applying them.- name: Deploy to commit
run: php artisan disparity:deployment:migrate ${{ github.sha }}
Abandoned Project:
Doctrine Migrations:
--display-sql.Composer Lock Conflicts:
composer.lock may cause dependency conflicts.composer update post-migration if needed.Laravel-Specific Issues:
// app/Console/Commands/DisparityDeploy.php
public function handle() {
$symfonyProcess = new Process(['php', 'app/console', 'disparity:deployment:migrate', $this->argument('target')]);
$symfonyProcess->run();
$this->output->write($symfonyProcess->getOutput());
}
Disparity\DeploymentBundle doesn’t conflict with Laravel’s autoloader.Git Configuration:
.git directory. Verify with:
git rev-parse --is-inside-work-tree
-vvv to the command for detailed logs.git status
git diff HEAD
postMigration events to debug migration failures.Custom Migration Logic:
MigrateCommand class to add pre/post-migration steps (e.g., cache clearing).// app/Disparity/DeploymentBundle/Command/CustomMigrateCommand.php
class CustomMigrateCommand extends MigrateCommand {
protected function postMigration() {
Artisan::call('cache:clear');
}
}
Configuration:
disparity_deployment config keys (check Resources/config/config.yml if available).# app/config/config.yml
disparity_deployment:
clean_before_migrate: true
Event Listeners:
disparity.deployment.migrated), create listeners in Laravel’s EventServiceProvider:
protected $listen = [
'disparity.deployment.migrated' => [
\App\Listeners\LogDeployment::class,
],
];
---
```markdown
## **WARNING**
This package is **abandoned**. For production use, consider:
1. **Git Hooks**: [Disparity’s Git Hooks](https://github.com/Disparity/git-hooks) (recommended).
2. **Alternatives**:
- Laravel: Use [`deployer`](https://deployer.org/) or custom Artisan commands.
- Symfony: [`symfony/lock`](https://symfony.com/doc/current/components/lock.html) + Git scripts.
How can I help you explore Laravel packages today?