Making changes to your site can be risky. You might break a functionality that would deter potential readers or customers. Every developer should take steps to make sure all changes can be tested before going live, and local development tools are an easy way to do that. Using local development tools will save you a lot of headaches down the road. Setting up a local server with the right tools is quite important and should be taken into account.
Production Server vs. Local Server
If you’ve been into theme or plugin development, then I’m sure you’ll be familiar these two terms. A production server, or live server, deploys and hosts live websites. Whereas, a local server provides a development environment similar to the production server which ultimately hosts your WordPress installation.
In between these two, is the development server. It helps you to host a staging area for your website. After developing a theme on a local server, you can test and debug it on a development server. Once the things are finalized, you can move it to the live server.
Why is Local Development Important?
Configuring a local setup to develop a WordPress theme is beneficial for a variety of reasons:
- The local environment is better since it does not require an internet connection.
- You can test and debug things without influencing/hindering others.
- You can work remotely where you have no access to the company network.
- Local development saves time as you can instantly view the changes in your browser. Local means fast.
- There are a number of other similar benefits.
WordPress Local Development Environment
When you talk about local development environment in WordPress, the starting point is a local server stack. Again it comes with different options like:
- Local Server: Local servers include tools like MAMP, DesktopSever which are configured on a local machine.
- Virtual Environment: Such a virtualized environment is built with tools like Vagrant and VirtualBox. These allow you to create easily reproducible development environments. Varying Vagrant Vagrants (VVV) is a famous Vagrant option which I’ll discuss shortly. And a few Docker-based tools as well.
I love finding and using new dev tools. Let’s take a look at some these new tools which you should try out this year.
Desktop Server by ServerPress allows you to create local dev sites for developing WordPress themes and plugins. It is powered by XAMP. You can also use custom host names like the one I use for my local dev testing site, local.dev, versus my local dev testing site, whereas wpra.dev is the local site where I test WP Rest API related stuff.
With DesktopServer you can set up a local host for WordPress in less than a minute. It has outclassed several other local tools regarding performance. You don’t have to manually edit any files, like wp-config.php or .htaccess. Its free version allows you to install up to three WP sites, but I would recommend upgrading to premium to get more features.
This is one of the easiest local dev setup tools and is, for the most part, error-free. I even have a core contribution setup with DesktopServer. Moreover, the folks at ServerPress are involved with the WordPress community. That in my book is a commendable quality for a company to have.
Some local development tools depend on an underlying OS that is difficult to set up. Local by Flywheel solves most of such issues. Previously it was known as Pressmatic but changed the name after being acquired by Flywheel last year. It has made WordPress local development with a Docker-based setup very easy.
It offers almost every feature you require to set up local WordPress installs and allows you to manage multiple local installs and that too from a single dashboard. That way, you can use the templates for future use. All of this is free.
I recommend it for its speed and flexibility. Hot-swap between NGINX or Apache 2.4, or switch between PHP versions. You can choose which version of PHP you want with any particular site, and you can change the PHP version after the local dev install is running (per site). Local site SSL makes all the difference when you are working with APIs and need SSL confirmation both on the client and server side.
Before DesktopServer, MAMP was my go-to solution to create a local environment on Mac OS X by installing PHP, MySQL, and Apache (and now also Nginx). Originally, it was developed for Mac users, but it now runs on Windows as well. It is considered to be one of the most traditional ways to run WordPress locally.
MAMP has stepped up their game and now you can build with NGINX, and change the PHP versions as well. It’s worth checking out.
VVV is a popular open source Vagrant configuration for setting up WordPress locally. Vagrant is a suite of tools which run on top of a virtual machine (like VMW are and VirtualBox) in your local environment. This means that both these virtual machines and your code are run together to maintain the local workflow.
VVV’s feature-rich toolkit allows you to build WP sites, build plugins and even debug. It also offers tools like WP-CLI, PHP Code Sniffer, and Composer to step up your development skills and mimic a production environment as much as it is possible.
VVV is created by a huge WP VIP agency 10up, though, it had transitioned to a community organization in 2014. Also, check out vv if you plan to use VVV. vv makes it extremely easy to create a new WordPress site using Varying Vagrant Vagrants.
Chassis is yet another incredible virtual server that is built with Vagrant. Without setting up anything, you can run WordPress locally with great ease. It is quite lightweight, and its folder structure is a bit different when compared to other Vagrant severs. Chassis install is self-contained.
Chassis allows you to add additional testing domains via a YAML configuration file. It also supports WordPress Multisite which makes it a setup more close to many managed WP hosting environments. The best part about it is that its a light weight alternative to VVV.
The most exciting thing about this project is the new Chassis Desktop. It looks pretty promising and extendable. While it is still in beta, you can go ahead and try it out. Chassis Desktop is an Electron application and uses build tools based on Create React App. Node.js/npm is required to build Desktop.
Chassis is a community project, with commercial support from Human Made .
If you’ve studied PHP carefully, then you must be aware of Laravel. Quite recently, their team launched a toolkit named Valet, or more precisely Laravel Valet. It creates a local development environment quite intuitively. An interesting feature about Laravel Valet is that there is no Vagrant, Apache, Nginx, etc. involved.
You can share your sites publicly using local tunnels. If you’re a WordPress developer and looking for an easy way to get started with a hassle free development environment, then Laravel Valet is a suitable option.
I’m particularly excited about one of the newest additions from 10up, WP Docker. They may have to change the name because it corresponds with another brand. You can read more about it in the announcement post.
WP Docker is all about speed and containment. A docker container per site with any configurations you want, without messing around with other dev setups you have, all contained in a fast loading container.
The WP Docker project includes PHP7, MariaDB, NGINX, Elasticsearch, Gearman, and Memcached. It is a powerful option for developing WordPress sites on your local machine.
Finally, you can catch all of my articles on my profile page, and you can follow me on my blog and/or reach out at Twitter @MrAhmadAwais; where I write about development workflows in the context of WordPress.
As usual, don’t hesitate to leave any questions or comments below, and I’ll aim to respond to each of them.