Using Chassis for WordPress Development
When I wrote the first article on WordPress and Vagrant I introduced WordPress VVV. VVV is a Vagrant configuration for developing WordPress themes and contributing to the core. One common problem, however, is that many people were overwhelmed with VVV. Especially those new to Vagrant, who just wanted to get something simple up and running fast. There are many other Vagrant configurations, one of the easiest to use and most popular in WordPress circles is Chassis.
Chassis is a simple Vagrant configuration, popular among WordPress plugin and theme developers. It’s easy to get started with and use on a per project development. In this article I’ll walk you through setting up Chassis. The folder structure is a bit different, so we’ll get into that too. The Chassis configuration has a hierarchy, so understanding how that works is also important. The last topic we’ll cover is extending Chassis by adding plugins that include more features.
Why Use Chassis?
There are several reasons why someone would choose to use Chassis for WordPress development. Firstly, Chassis is lightweight. In contrast, VVV is rather heavy as it comes with a wide range of tools. The problem with VVV is that it can take a long time to install, and it’s slow. In comparison, Chassis takes just a couple of minutes to install.
Chassis is so lightweight, that it only comes with:
- WordPress 4.0
- PHP 5.4 (includes the cURL and GD extensions)
Where is phpMyAdmin? Everything else that you may want to install, such as phpMyAdmin for example, comes as an extension. Memcache is also available, Xdebug is comming soon.
The installation is easy and the Chassis documentation covers it very well. You need to install the latest version of Vagrant and VirtualBox. However, Chassis requires an additional tool to work with the network. You can choose either Bonjour or Avahi. If you’re on Mac then you will already have Bonjour pre-installed. If you’re on Windows you can install Bonjour via iTunes. If you use Linux then you’ll have to install Avahi by executing:
sudo apt-get install avahi-dnsconfd
You can get a copy of Chassis from the GitHub repo, just execute:
git clone http://github.com/Chassis/Chassis.git chassis
git submodule update –init
git submodule update --init makes sure you download every submodule.
A nice feature of Chassis is the separation of the WordPress and development directories. By default the folder that contains the themes, plugins and uploads folder is the content folder. When you first clone the repository, there is no content folder. The WordPress folder is called
wp but there is no content folder. You can start creating the folder yourself and build the structure. The team behind Chassis has a predefined content folder available on GitHub (called ‘Supercharger’). Supercharger comes with some plugins, such as WordPress SEO, WordPress Importer, Limit Login Attempts and the Regenerate Thumbnails plugin.
git clone https://github.com/Chassis/Supercharger.git content
git submodule update –init
To get up and running, you only need to
vagrant up and everything will be installed. Chassis uses a ‘precise64’ box by default. The first time you
vagrant up the project the box will be downloaded if no other Vagrant configuration has used it before. To do this, navigate to the root of the project and then execute:
Wait until the installation finishes. You now have a ready to use environment. Everything is pre-configured, there’s no need for the famous 5 minutes configuration. After the installation finishes, visit
http://vagrant.local/ in your browser and see if it works. You should see a ready to use WordPress site, skipping the installation process.
You may have noticed that after installation there are two new files. The
local-config-db.php file and
local-config-extensions.php. Don’t edit these files. They’re generated using the
config.yaml configuration. If you want to edit these files, you’ll need to edit
config.yaml and then provision using
Folder Structure and the Configuration Hierarchy
Chassis separates the WordPress folder from the content folder. By default, Chassis disables the auto-update so you’ll have to install any updates manually. Separating the folders is a good decision. Using this separate content folder doesn’t mean that you can’t work with the
wp-content folder, but it’s better to stick with the
config.yaml has a hierarchy.
config.local.yaml has the highest priority then
config.yaml in the content folder. By default these configuration files don’t come with Supercharger. You can copy the existing file from the root folder of the project.
config.local.yaml in the root folder of the project have the least priority.
config.local.yaml always has the highest priority in the particular folder.
When you start with a fresh folder you’ll only have one
config.yaml in the root folder. This is the lowest priority. Inside that file you can configure the PHP version (5.4 by default), the WordPress directory (/wp by default), the database configuration and WordPress credentials.
Let’s experiment a little. First open
vagrant.local/phpinfo.php to see what PHP version you’re using. By default you start with 5.4. Copy the
config.yaml to the content folder. Edit the PHP version and set it to 5.5. Execute
vagrant provision and after the provision navigate again to
config.yaml from the content folder and rename the copy you just created to
config.local.yaml. Again, edit the PHP version to 5.4 again. Execute
vagrant provision and test it in your browser.
Try the same thing with the admin configuration. On
config.local.yaml edit the password to “thepassword”. Execute
vagrant provision again and test it to login in with this password on the dashboard. The password is wrong. So why is that? You can’t change the password or the admin credentials via provision. However, if you
vagrant destroy and
vagrant up again, you will see that the password for the admin is now “thepassword”.
Be careful with this configuration. Try to separate the local configuration from the deployment configuration.
Plugins for Chassis
Chassis supports extensions, I’ll cover a few of the popular ones.
As you can see from the name and icon, this is a tool that catches emails that are sent to it and displays those in a web interface. This tool is used for testing purposes, when you don’t want emails sent to a real email provider, but you also need to see if it works. Installing this tool using Chassis is easy so you don’t have to worry about configuring anything.
git clone https://github.com/Chassis/mailcatcher.git mailcatcher
git submodule update –init
Copy the Mailcatcher repository on Chassis to the
extensions folder and then
vagrant provision. Now go and add a comment to a post. Navigate to
http://vagrant.local:1080/ and you will see that mailcatcher has ‘caught’ the email.
I don’t think that this tool needs any introduction. This is one of the most popular tools when dealing with databases. Just like MailCatcher, this extension doesn’t need any configuration at your end. The installation is similar to MailCatcher.
git clone https://github.com/Chassis/phpMyAdmin.git phpmyadmin
Now navigate to
vagrant.local/phpmyadmin and you’ll see that no login is required.
When you’re developing a website with WordPress, you don’t know for sure how much traffic the website is going to get. High volumes of traffic is a nice thing, but have you thought about how you’re going to handle it? It’s possible that your server will crash from the huge amount of requests, or in the best case scenario your site will become slow. This is where caching comes in. This is the definition of Wikipedia for Memcached:
Memcached is a general-purpose distributed memory caching system. It is often used to speed up dynamic database-driven websites by caching data and objects in RAM to reduce the number of times an external data source (such as a database or API) must be read.
The Memcache extension installs Memcached properly, you can read the documentation for information on how to use this extension.
Using Vagrant and Chassis is one of the easiest to use and fastest environments for WordPress development. It has a good workflow by separating the WordPress installation from the working folder. It’s also simple, yet powerful when it comes to extensions.