Deployer tasks and recipes for deploying WordPress sites. Supports simple rsync deployments, custom theme/plugin builds, and complex setups including Bedrock and multisite.
- Deployer WordPress Recipes
composer require gaambo/deployer-wordpress --dev- Copy example files from
examples/simple/orexamples/bedrock/to your project root - Customize
deploy.phpanddeploy.yml:
- Set
current_pathfor all hosts (remote + localhost) - Configure custom code as packages
- Adjust deployment flow if needed
- Test on staging first, then deploy to production 🚀
- PHP + Composer
- Deployer (automatically installed)
- WordPress installation
- *nix OS (Linux/macOS or WSL on Windows)
rsyncinstalled
Optional (auto-installed on remote if missing):
- WP-CLI for database tasks
- Composer for package vendors (depending on your custom theme/plugins)
- Node.js/npm for building assets (depending on your custom theme/plugins)
Example recipes (in examples/) provide configuration starting points. The library works with any WordPress setup (
vanilla, Composer, subdirectory, Bedrock, multisite) by making all paths and directories configurable. Check the example
recipes and task source files for available options.
Version 4 introduces a proper Localhost context. This ensures that when tasks run on your local machine
(like building assets or backing up the local database), they use configuration values specifically defined for
localhost, rather than falling back to global or remote values.
Configure localhost in deploy.php:
localhost()
->set('public_url', 'http://wp-boilerplate.test')
->set('current_path', 'public') // WordPress root
->set('dbdump_path', __DIR__ . '/data/db_dumps')
->set('backup_path', __DIR__ . '/data/backups');The Localhost utility class (Gaambo\DeployerWordpress\Localhost) handles switching context automatically in tasks.
Keep wp-config.php in git and deploy it. Extract environment-specific config (database credentials, WP_DEBUG) into
wp-config-local.php, which should be gitignored and created manually on each host. Require it from wp-config.php:
if (file_exists(__DIR__ . '/wp-config-local.php')) {
require_once __DIR__ . '/wp-config-local.php';
}The default rsync config uses .deployfilter files for per-directory filtering. Place a .deployfilter file in your
theme/plugin to exclude development files:
- phpcs.xml
- README.md
- .babelrc
- node_modules
- .eslintignore
- .eslintrc.json
- .stylelintignore
- .stylelintrc.json
- gulp.config.js
- gulpfile.babel.js
- package.json
- package-lock.json
- .babelrc
- phpcs.xml
This prevents any development files/development tools from syncing. I strongly recommend you put something like this in
your custom theme and mu-plugins or overwrite any of the themes/filter or mu-plugins/filter configurations.
Tasks are in the tasks/ directory. Run dep list to see all available tasks. See task source files for configuration
options.
db:remote:backup: Backup remote database and download to localhostdb:local:backup: Backup local database and upload to remote hostdb:remote:import: Import current database backup (from localhost) on remote hostdb:local:import: Import current database backup (from remote host) on local hostdb:push: Pushes local database to remote host (combinesdb:local:backupanddb:remote:import)db:pull: Pulls remote database to localhost (combinesdb:remote:backupanddb:local:import)
For multisite installations, set wp/multisite to true to enable network-wide search-replace during database sync:
set('wp/multisite', true);Manage custom themes, plugins, and mu-plugins with individual build configs:
set('packages', [
'custom-theme' => [
'path' => '{{themes/dir}}/custom-theme',
'remote:path' => '{{themes/dir}}/custom-theme', // optional
'assets' => true,
'assets:build_script' => 'build',
'vendors' => true, // Run composer install
],
// Add more packages as needed
]);Tasks:
packages:assets:vendors- Install npm dependenciespackages:assets:build- Run build scriptspackages:vendors- Install composer dependenciespackages:push/packages:pull- Sync packages
File Tasks (tasks/files.php)
files:push/files:pull- Sync all files (combines wp, uploads, plugins, themes, packages)
WordPress Core (tasks/wp.php)
wp:download-core,wp:push,wp:pull,wp:info
Languages (tasks/languages.php)
languages:push,languages:pull,languages:sync,languages:backup:*
Uploads (tasks/uploads.php)
uploads:push,uploads:pull,uploads:sync,uploads:backup:*
Legacy Tasks (use packages instead)
- Themes:
themes:push,themes:pull - Plugins:
plugins:push,plugins:pull - MU-Plugins:
mu-plugins:push,mu-plugins:pull
v4 uses current_path for rsync-based deployments. Symlinked releases are still possible but not the default.
recipes/simple.php - Standard WordPress. Rsyncs directly to current_path. Recommended for most projects.
recipes/bedrock.php - Roots Bedrock projects with appropriate structure and
environment handling.
See CHANGELOG.md.
Issues, feature requests, and pull requests welcome at GitHub. Code follows PSR-2 and Deployer best practices.
The library includes a comprehensive test suite with unit, integration, and functional tests.
- Run
composer phpunitto execute all tests. - Functional tests use a mocked environment to verify rsync commands and file operations without real remote connections.