Composer Template for WordPress Projects
This project template should provide a kickstart for managing your site dependencies with Composer.
This project consist of:
- WordPress core: johnpbloch/wordpress-core-installer
- Repository https://wpackagist.org/ to install WordPress plugins and themes
composer/installersto set custom paths for plugins and themes
drupal-composer/preserve-pathsto exclude paths for plugins and themes under version control
composer install. You can remove it if you're not using Wodby
Current WordPress core:
By default, wordpress core will be installed in
./web directory. Plugins and themes will be installed in
./web/wp-content/themes. Point your Apache vhost or similar to this project's
First you need to install composer.
Note: The instructions below refer to the global composer installation. You might need to replace
php composer.phar(or similar) for your setup.
Start a new project:
composer create-project wodby/wordpress-composer some-dir --stability dev --no-interaction
composer create-project command passes ownership of all files to the project that is created. You should create a new git repository, and commit all files not excluded by the .gitignore file.
How to install WordPress plugins and themes?
composer require ... you can download new dependencies to your installation.
cd some-dir composer require wpackagist-plugin/wp-cfm
How to manage my custom themes and plugins under version control?
- Exclude path to your plugin or theme from .gitignore. Example for theme under
!web/ web/* !web/wp-content/ web/wp-content/* !web/wp-content/themes/ web/wp-content/themes/* !web/wp-content/themes/my-custom-theme/
- Add the same path to your composer.json under
extra > preserve-paths:
"preserve-paths": [ "web/wp-content/themes/custom" ]
- Add your plugin/theme directory under version control
composer install. Composer will install WordPress core and keep your custom theme
Deployment via Wodby
- Create a new project.
- Connect the repository to Wodby.
- Deploy new app, choose WordPress stack, on the 2nd step of the form choose connected repository and enter
webas Codebase dir.