A lightweight layer for running post-deploy synchronisations, similar to migrations but kept separate. It only executes sync files that have not been run before, making it handy for CI/CD pipelines or multi-database setups where environments may be out of sync.
- PHP ^8.0
- Laravel 11.41.3^/12^
composer require rapide-software/sync-stackThe service provider is auto-discovered.
- Create the tracking table migration (defaults to
synchronisations):
php artisan sync:migrate
php artisan migrateUse --path to place the migration elsewhere or --realpath for absolute paths.
- (Optional) Choose where your sync files live. By default they sit in
app/Synchronisationsusing StudlyCase folders. Pass--locationto any sync command to override, or--fromBasePathto target an absolute path underbase_path().
Generate a new sync file (timestamped automatically):
php artisan sync:create --name="update_permissions" --location=Synchronisations--abstractClass lets you extend your own base class for shared helpers. As of yet, this feature is very barebones and simply writes the extends line for you.
Each sync is an anonymous class with two hooks:
return new class {
public function sync(): void {
// Synchronize what you want synchronized.
}
public function rollback(): void {
// Rollback logic to undo your synchronization
}
};Execute only the sync files that have not run yet:
php artisan sync:run --location=Synchronisations- Files are discovered recursively under
--locationand keyed by their path in thesynchronisationstable. - Each run uses the next batch number;
--continueOnFailurekeeps going after an error.
Undo the most recent batch of syncs:
php artisan sync:rollback --location=Synchronisations- Only the latest batch is rolled back; earlier batches stay intact.
- Use
--continueOnFailureto attempt the rest even if one rollback fails.
MIT