brazilianfriendsofsymfony/sync-content-bundle
Installation
Clone the repository into your Symfony2 project’s vendor/bundles directory:
git clone git://github.com/BrazilianFriendsOfSymfony/BFOSSyncContentBundle.git bundles/BFOS/SyncContentBundle
Run php bin/vendors install to ensure dependencies are resolved.
Enable the Bundle
Add to app/AppKernel.php under dev/test environments:
$bundles[] = new BFOS\SyncContentBundle\BFOSSyncContentBundle();
Basic Configuration
Add to app/config/config_dev.yml:
bfos_sync_content:
options:
deployment:
rsync_exclude:
- "%kernel.root_dir%/config/rsync_exclude.txt"
First Sync Run the sync command:
php app/console bfos:sync-content
php app/console list bfos to see available commands.app/config/config_dev.yml for sync options.%kernel.root_dir%/config/rsync_exclude.txt to define files/folders to ignore.Local Development Sync
Use bfos:sync-content to push local changes to a remote server during development:
php app/console bfos:sync-content --env=dev
Pre/Post-Sync Hooks
Leverage pre_local_commands/post_local_commands for tasks like asset compilation:
bfos_sync_content:
options:
deployment:
pre_local_commands:
- 'php app/console assetic:dump --env=dev'
post_local_commands:
- 'rm -rf web/cache/dev'
Remote Server Commands Execute commands on the remote server post-sync (e.g., restarting services):
bfos_sync_content:
options:
deployment:
post_remote_commands:
- 'sudo service apache2 restart'
config_dev.yml for test/prod environments (e.g., different remote paths or commands).rsync_exclude to skip vendor/, logs/, or .git/:
rsync_exclude:
- "%kernel.root_dir%/../vendor"
- "%kernel.root_dir%/../app/logs"
php app/console bfos:sync-content --dry-run
Environment Restrictions
The bundle is only enabled in dev/test environments by default. Explicitly add it to prod if needed (not recommended for security).
Rsync Dependencies
Ensure rsync is installed on both local and remote machines. Test with:
rsync --version
Permission Issues
Remote commands (e.g., post_remote_commands) require SSH access with proper permissions. Use keys or passwordless logins:
ssh-copy-id user@remote-server
Configuration Overrides
Global options in config_dev.yml cannot be overridden per-command. Use environment-specific configs instead.
php app/console bfos:sync-content -vvv
Custom Commands
Extend the bundle by creating a custom command that inherits from BFOS\SyncContentBundle\Command\SyncContentCommand.
Event Listeners
Hook into sync events (e.g., pre/post-sync) by implementing BFOS\SyncContentBundle\Event\SyncContentEvents.
Dynamic Exclusions
Use Twig or PHP logic to generate rsync_exclude dynamically (e.g., exclude files matching a pattern):
rsync_exclude:
- "%kernel.root_dir%/../app/config/local/%env(APP_ENV)%/*.yml"
How can I help you explore Laravel packages today?