Craig Simpson

Web developer from Moray, Scotland

Creating a new project boilerplate using Composer and WPStarter

21st April 2017

No Comments

I love finding ways to improve my efficiency as a developer. One such advancement recently has been my adoption of WPStarter for managing WordPress installations using Composer.

Using WPStarter I’ve created a new project boilerplate which I can use to quickly spin up a new WordPress website with a simple composer install. In the project composer.json I can declare plugin and theme dependencies, and also include plugins which are only to be used in the development stage. Using SatisPress, I can also manage the availability of premium plugins for my project bootstrap file and keep them up to date automatically.

After creating a new site (locally, or remotely), I can navigate to the site root in the command line and clone my new project boilerplate. Running composer install will then download and configure my WordPress installation with the themes and plugins detailed in my composer.json file. For example:

mkdir project && cd project
git clone git@github.com:craigsimps/new-project-boilerplate .
composer install

When the installation is complete, all that’s required is to rename .env.example to .env and then set the environment variables (database name, username and password at the most basic level) in the file. After that, if I’m using my Genesis starter theme then I’ll perform an npm install and gulp build to kick things off there.

As this new project develops, the boilerplate will be updated become a separate bootstrap repository for that site, so it can be used to quickly spin up the finished website, whether it’s on localhost for further development, or on the server when the site is deployed.

It’s important to note that my repository also contains a few other helpful files. The .htaccess file included will rewrite the dashboard URLs to remove the subdirectory path /wp/ which WordPress core is installed into. The .editorconfig file helps make sure that code style is consistent across all sites I create, and the .gitignore file makes sure that no plugin or theme files are committed as I work on the project bootstrap repository.

Leave a Reply

Your email address will not be published. Required fields are marked *