Bootstrapping WordPress With Composer
How we’ve optimized our WordPress project setup process
At 76design, a major portion of our client work includes WordPress deploys and over the past couple of years, we’ve built a set of tools, base themes, and processes that help us complete these projects. For example, here’s a list of these components:
- WordPress (http://wordpress.org/)
- WordPress Roots starter theme (http://roots.io/)
- WordPress Advanced Custom Fields plugin (http://www.advancedcustomfields.com/) and others.
- Bootstrap (http://getbootstrap.com/) web framework; the SASS version (https://github.com/jlong/sass-bootstrap)
- Compass for CSS compilation (http://compass-style.org/)
- Phing deployment scripts
We set up a base WordPress project in the past that includes some of these components to help with our project setup but it could still be relatively lengthy (most of our time being spent setting up new deployment scripts and ensuring they work with the new project).
Our current process to setup a WordPress project looks like this:
- Create a copy of our base svn WordPress project in SVN.
- Checkout the new project.
- Update the Roots theme with the latest version.
- Rename our Roots child theme.
- Update our Bootstrap SASS files with the newest version of Bootstrap.
- Make a copy of the phing deployment scripts from a previous WordPress project and update them for the new project.
Using these new tools, and the composers create-project functionality, we felt we could significantly improve and optimize the process by which we setup our WordPress projects, as well as similar CMS projects such as Drupal. To help with this is WP Packagist (http://wpackagist.org) which is a package repository for WordPress plugins.
We started by creating a base project, similar to what we already had, but with the inclusion of composer, to install the latest versions of WordPress, the WordPress Roots starter theme, and base WordPress plugins, and bower to install the latest version of Bootstrap for SASS. From there, we added a build directory which houses the generalized deployment scripts. Where pertinent, we added strings that will be replaced with project specific names (for example, theme folder name and project name). To replace these strings, we created a phing script that can be run after the initial installation and accept input for setting the project name and theme folder name. All of this was added to a project in our SVN repository and the project now doubles as a composer package within our custom composer package repository.
Now, our WordPress project setup process looks like this:
- Run Composer create-project.
- Run the phing rename script.
- Create svn project.
And with that, our WordPress project setup time has been reduced to 5 – 10 mins.
Are there any tools or process not mentioned here that you use and could help improve this process? Did this help your current setup process? We’d love to hear about it.
We’ve made the base project available on our github account – 76design/wordpress-base.