{"id":19664587,"url":"https://github.com/sourcebroker/deployer-extended-wordpress","last_synced_at":"2025-08-10T22:08:39.773Z","repository":{"id":57056080,"uuid":"95110153","full_name":"sourcebroker/deployer-extended-wordpress","owner":"sourcebroker","description":"Deployer based deployment for WordPress with media and database synchronisation.","archived":false,"fork":false,"pushed_at":"2023-02-07T22:07:15.000Z","size":67,"stargazers_count":22,"open_issues_count":0,"forks_count":4,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-10-10T18:14:25.814Z","etag":null,"topics":["deployer","deployer-recipes","deployment","deployments","php","sb-dew","wordpress"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sourcebroker.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-22T11:51:13.000Z","updated_at":"2024-10-07T04:28:37.000Z","dependencies_parsed_at":"2023-01-27T05:31:23.209Z","dependency_job_id":null,"html_url":"https://github.com/sourcebroker/deployer-extended-wordpress","commit_stats":null,"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcebroker%2Fdeployer-extended-wordpress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcebroker%2Fdeployer-extended-wordpress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcebroker%2Fdeployer-extended-wordpress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcebroker%2Fdeployer-extended-wordpress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sourcebroker","download_url":"https://codeload.github.com/sourcebroker/deployer-extended-wordpress/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224133770,"owners_count":17261303,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deployer","deployer-recipes","deployment","deployments","php","sb-dew","wordpress"],"created_at":"2024-11-11T16:18:17.477Z","updated_at":"2025-04-28T21:33:42.953Z","avatar_url":"https://github.com/sourcebroker.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"deployer-extended-wordpress\n===========================\n\n.. contents:: :local:\n\nWhat does it do?\n----------------\n\nThis package provides deploy task for deploying WordPress with deployer (deployer.org) and additionally a tasks\nto synchronize database and media files.\n\nThe deployment is simplified in order to have ability to auto-upgrade WordPress and upgrade plugins\nmanually by admin panel (or automatically with tools like InfiniteWP). This is a half way between\nno deployment at all and deployment fully driven by composer. If you want to manage WordPress and plugins\nfully with composer then check https://roots.io/ and `sourcebroker/deployer-extended-wordpress-composer`_.\n\n\nShould I use \"deployer-extended-wordpress\" or \"deployer-extended-wordpress-composer\"?\n-------------------------------------------------------------------------------------\n\nIn `sourcebroker/deployer-extended-wordpress`_ the WordPress and third party plugins are installed manually. What you\nhave in GIT is basically only your theme/plugins/muplugins. The good thing is that in such case you can update WordPress and plugins\nautomatically. This can be considered as preferable for low budget WordPress websites.\n\nIn `sourcebroker/deployer-extended-wordpress-composer`_ the WordPress and third party plugins are installed using composer.\nThis way you gain more control over what is installed but at the same time to install new WordPress or new plugin\nversion you need first to modify composer.json or do composer update (depending how big upgrade you do). Then you need\nto commit composer.json / composer.lock and do deploy which will install new version of WordPress and plugins.\nThis is additional work that can not be easily automated. One of additional advantages of this solution is that you can\neasily cleanup infected WordPress/plugins files as with each deployment all php files are fresh (part from your GIT\nand part from composer repositories).\n\nDependencies\n------------\n\nThis package depends on following packages:\n\n- | `sourcebroker/deployer-extended`_\n  | Package which provides some deployer tasks that can be used for any framework or CMS.\n\n- | `sourcebroker/deployer-extended-database`_\n  | Package which provides some php framework independent deployer tasks to synchronize database.\n\n- | `sourcebroker/deployer-extended-media`_\n  | Package which provides some php framework independent deployer tasks to synchronize media.\n\n- | `wp-cli/search-replace-command`_\n  | Package to change domains after database synchronization. Part of wp-cli/wp-cli utility.\n\n\nInstallation\n------------\n\n1) Install package with composer:\n   ::\n\n      composer require sourcebroker/deployer-extended-wordpress\n\n2) Put following lines in your deploy.php:\n   ::\n\n      require __DIR__ . '/vendor/autoload.php';\n      new \\SourceBroker\\DeployerExtendedWordpress\\Loader();\n\n3) Remove task \"deploy\" from your deploy.php. Otherwise you will overwrite deploy task defined in\n   deployer/deploy/task/deploy.php\n\n4) Example deploy.php file:\n   ::\n\n      \u003c?php\n\n      namespace Deployer;\n\n      require __DIR__.'/vendor/autoload.php';\n      new \\SourceBroker\\DeployerExtendedWordpress\\Loader();\n\n      set('repository', 'git@my-git:my-project.git');\n\n      host('live')\n          -\u003esetHostname('example.com')\n          -\u003esetRemoteUser('deploy')\n          -\u003eset('shared_files', array_merge(get('shared_files'), ['config/.env.live.local']))\n          -\u003eset('public_urls', ['https://www.example.com/'])\n          -\u003eset('deploy_path', '/var/www/example.com/live');\n\n      host('beta')\n          -\u003esetHostname('example.com')\n          -\u003esetRemoteUser('deploy')\n          -\u003eset('shared_files', array_merge(get('shared_files'), ['config/.env.beta.local']))\n          -\u003eset('public_urls', ['https://beta.example.com/'])\n          -\u003eset('deploy_path', '/var/www/example.com/beta');\n\n      host('dev')\n          -\u003eset('public_urls', ['https://example-com.ddev.site/'])\n          -\u003eset('deploy_path', getcwd());\n\n\nMind the declaration of host('dev'); Its needed for database tasks to declare domain replacements,\nand path to store database dumps.\n\nProject's folders structure\n---------------------------\n\nThis deployment has following assumptions:\n\n1) WordPress source code is not in GIT in order to have ability to easily upgrade them from admin panel.\n2) ``wp-content/plugins`` should be most out of GIT to in order to have ability to easily upgrade them from admin panel.\n   You can have however some plugins in GIT if you like.\n3) ``wp-content/mu-plugins`` can be partially out of GIT but you can also have plugins there which are in GIT.\n4) ``config/environments`` and use of ``wp-config`` and ``.env`` idea is back ported from bedrock and extended with idea of ``symfony/dotenv``\n5) Taking the above points into consideration the only files in GIT will be:\n   ::\n\n        /config/environments/development.php\n        /config/environments/staging.php\n        /config/application.php\n        /config/.env\n        /config/.env.beta\n        /config/.env.dev\n        /config/.env.live\n        /config/.env.dev.local.dist\n        /config/.htaccess\n        /wp-content/plugins/my-plugin-in-git\n        /wp-content/mu-plugins/my-mu-plugin.php\n        /wp-content/themes/my-theme/\n        .gitignore\n        deploy.php\n        composer.lock\n        composer.json\n        wp-config.php\n\nMind ``.env.beta``, ``.env.dev``, ``.env.live`` - those files stores data which is specific per instance but can be\nstored in git. For example database name, database user, database host, SMTP settings (without passwords). The passwords\nshould be stored in file which is out of git on each of the instance host ``.env.beta.local``, ``.env.dev.local``,\n``.env.live.local`` or if you do not mind so much about security you can store them also in git.\n\nYou need also to add shared local env file per instance. You can do it like this. Look at line 4:\n ::\n\n  host('live')\n   -\u003esetHostname('example.com')\n   -\u003esetRemoteUser('deploy')\n   -\u003eset('shared_files', array_merge(get('shared_files'), ['config/.env.live.local']))\n   -\u003eset('public_urls', ['https://www.example.com/'])\n   -\u003eset('deploy_path', '/var/www/example.com/live');\n\nThe only required, out of git file on instance is ``/config/.env.local`` where you set info what instance it is.\nThe content of ``/config/.env.local`` should be only ``WP_INSTANCE='live'`` etc depending on which instance it is.\n\n\nThe shared dirs defined in ``deployer/set.php`` are:\n ::\n\n    set('shared_dirs', [\n            'wp-content/uploads',\n            'wp-content/languages',\n            'wp-content/upgrade',\n        ]\n    );\n\nThe shared files defined in ``deployer/set.php``are:\n ::\n\n    set('shared_files', [\n        '.htaccess',\n        'config/.env.local',\n    ]);\n\n\nComposer\n--------\n\nYou can set proper version of composer with ``composer_channel`` (values: 1, 2, stable, prelive, snapshot) or with\n``composer_version`` which takes exact tags as arguments (https://github.com/composer/composer/tags). For stability and\nsecurity  its advised that you set ``composer_channel`` with value ``1`` or ``2`` so it will be automatically updated\nbut will not install any new major version in future so your deploy will remain fairly stable.\n\n::\n\n   set('composer_channel', 2);\n\n\nSynchronizing database\n----------------------\n\nDatabase synchronization is done with `sourcebroker/deployer-extended-database`_.\nExample of command for synchronizing database from live to local instance:\n::\n\n   dep db:pull live\n\n\nDomain replacement\n++++++++++++++++++\n\nThe \"post_command\" task \"db:import:post_command:wp_domains\" will change domains declared in \"public_urls\". Domain\nreplacement is done with cli command \"search-replace\" from `wp-cli/wp-cli`_.\n\nPlease mind to have the same amount of \"public_urls\" for each of instances because replacement on domains is done for\nevery pair of corresponding urls.\n\nLook at following example to give you idea:\n::\n\n    host('live')\n        -\u003esetHostname('example.com')\n        -\u003esetRemoteUser('deploy')\n        -\u003eset('shared_files', array_merge(get('shared_files'), ['config/.env.live.local']))\n        -\u003eset('public_urls', ['https://www.example.com', 'https://sub.example.com'])\n        -\u003eset('deploy_path', '/var/www/example.com.live');\n\n    host('beta')\n        -\u003esetHostname('example.com')\n        -\u003esetRemoteUser('deploy')\n        -\u003eset('shared_files', array_merge(get('shared_files'), ['config/.env.live.local']))\n        -\u003eset('public_urls', ['https://beta.example.com', 'https://beta-sub.example.com'])\n        -\u003eset('deploy_path', '/var/www/example.com.beta');\n\n    host('dev')\n        -\u003eset('public_urls', ['https://example-com.ddev.site', 'https://sub-example-com.ddev.site'])\n        -\u003eset('deploy_path', getcwd());\n\n\nThe if you will do:\n::\n\n    dep db:pull live\n\nthe following commands will be done automatically after database import:\n::\n\n    wp search-replace https://www.example.com https://example-com.dev\n    wp search-replace https://sub.example.com https://sub-example-com.dev\n\n\nConfiguration\n+++++++++++++\n\n\nMind that \"deploy.php\" file must be the same on all instance before you can start to do database synchronization.\n\n\nSynchronizing media \u0026 WordPress / plugins code\n----------------------------------------------\n\nMedia synchronization is done with package `sourcebroker/deployer-extended-media`_.\nThe command for synchronizing media \u0026 php files which are out of git is:\n ::\n\n   dep media:pull live\n\nBecause we do not use composer to get WordPress and plugins therefore we will treat here code of WordPress and\nplugins as kind of media to synchronize. This is a bit o misuse of `sourcebroker/deployer-extended-media`_ but\nif we think of media as part of project which is out of git that needs to be synchronized between instances then\nour WordPress and plugins php code which is also out of git is bunch of files that needs to be synchronized\nbetween instances.\n\nTherefore our config to synchronize files media \u0026 WordPress / plugins code looks like this:\n::\n\n    set('media',\n        [\n            'filter' =\u003e [\n                '+ /wp-content/',\n                '- /wp-content/mu-plugins/*',\n                '- /wp-content/themes/*',\n                '+ /wp-content/**',\n                '+ /wp-admin/',\n                '+ /wp-admin/**',\n                '+ /wp-includes/',\n                '+ /wp-includes/**',\n                '+ .htaccess',\n                '+ wp-activate.php',\n                '+ wp-blog-header.php',\n                '+ wp-comments-post.php',\n                '+ wp-config-sample.php',\n                '+ wp-config.php',\n                '+ wp-cron.php',\n                '+ wp-links-opml.php',\n                '+ wp-load.php',\n                '+ wp-login.php',\n                '+ wp-mail.php',\n                '+ wp-settings.php',\n                '+ wp-signup.php',\n                '+ wp-trackback.php',\n                '+ xmlrpc.php',\n                '+ index.php',\n                '- *'\n            ]\n        ]);\n\n\n\n.. _sourcebroker/deployer-extended: https://github.com/sourcebroker/deployer-extended\n.. _sourcebroker/deployer-extended-media: https://github.com/sourcebroker/deployer-extended-media\n.. _sourcebroker/deployer-extended-database: https://github.com/sourcebroker/deployer-extended-database\n.. _sourcebroker/deployer-extended-wordpress: https://github.com/sourcebroker/deployer-extended-wordpress\n.. _sourcebroker/wordpress-starter: https://github.com/sourcebroker/wordpress-starter\n.. _sourcebroker/deployer-extended-wordpress-composer: https://github.com/sourcebroker/deployer-extended-wordpress-composer\n.. _wp-cli/search-replace-command: https://github.com/wp-cli/search-replace-command\n.. _wp-cli/wp-cli: https://github.com/wp-cli/wp-cli\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourcebroker%2Fdeployer-extended-wordpress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsourcebroker%2Fdeployer-extended-wordpress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourcebroker%2Fdeployer-extended-wordpress/lists"}