Following along the lines of a Smashing Magazine article about Composer-managed WordPress installations I’ve created my version of it.
My workflow involves setting up a WordPress local installation to work on and make daily “commits” (it’s in quotes as it’s done via FTP and
git-ftp ) to the staging/live server.
I’ve modified Smashing Magazine guide to my own needs and taste and created composerpress; the name is not the most original ever seen yet it carries the message across.
Step by step process is, supposing
composer globally installed already, just 3 steps.
I keep my local installations in the
/www folder and will make those locally available using MAMP, at Terminal
cd /www git clone [email protected]:lucatume/composerpress.git client-site rm -rf .git* git init
client-site will be the name of the client I’m working for.
The last two lines will remove any bond to the
composerpress repository and initialize a new
I will then install the dependencies specified in the
composer.json file that came with the repository
cd client-site composer install
will wait for
composer to work its magic.
The last thing to do is to modify the
client-site/wp-config.php file to make it talk to the local MySql server.
Once MAMP or any other local hosting solution is set to serve the site from that folder the site will be ready to use and sport some plugins and Twentyfourteen theme.
WordPress makes installing plugins and themes easy using its administration interface but to keep the installation consistent that’s not the way to go. In this Composer-managed installation the right way is to go and modify the
composer.json file and run
If I want to install the Hello Dolly plugin I will go to WordPress plugin repository, will find it and take note of its “slug”
in this case
hello-dolly. I will add that to the site dependencies
and will then update the site installation using composer
The same goes for themes.
Removing themes and plugins requires just the deletion of the
require line in the
composer.json file and another update.
Since more complex plugins might use activation, deactivation and uninstallation hooks to allow all of those hooks to fire follow these steps to install a plugin:
- activate the plugin on the site
To remove a plugin:
- deactivate the plugin on the site
- remove the plugin from the site
composer.jsondependency removing the require statement
While the process above is two sites old managing plugin and themes dependencies via Composer is a recent (polite synonim of “never used before”) approach I’m testing right now: I will illustrate that as well in a next article.