WordPress Local Development: What It is and When to Use It
Not only can a local environment help streamline development, but it can save you a lot of time and hassle when deploying a site.
Below is a detailed look at what a WordPress local development environment is as well as when and how to use it to your advantage.
What is a Local Environment?
A local environment is a virtual web server that exists entirely on your computer with access to your files and database.
With traditional hosting, everything lives on the remote servers of a web hosting company. You can work with your site using their resources and your own internet connection.
A local environment removes the middleman in the development process. It lets you rely on whatever environment you want to configure so you can break and play with your code safely and independently.
This setup is also incredibly useful if you’re developing the WordPress core or with it.
According to the Make WordPress Core, “A local WordPress install allows you to create/test patches, find/fix bugs, and help develop/test new features during a release cycle.”
Why Use a WordPress Local Environment?
Local environments are a common development tool that are extremely useful for WordPress developers. Below are a few reasons why you may find one helpful.
Testing and Compatibility
When integrating a new and untested theme or plugin in your website, a number of things can go awry. If something is incompatible, it could take your whole site out.
It’s also not a good idea to test on a live site since it could break as users are trying to access it. Instead, work on a local site.
It helps ensure all aspects of your site from your theme and design to your plugins and content work well together and without error. This is known as compatibility.
Local environments are also useful to help you test your site from a variety of different perspectives in terms of browsers and screen sizes. This is called cross-browser testing.
It’s a pillar of web development testing since not everyone is viewing your website from the same configuration.
Testing all possibilities on a live site can also be cumbersome, time-consuming, and can sometimes yield inconsistent results when dynamic factors are at play such as users adding content as you’re testing, for example.
Similarly to testing, if certain theme or plugin updates are drastic, other elements of your site could change as well. The local environment gives you a barrier to make sure everything is compatible before deploying.
This also prevents visitors from seeing adjustments being made in real time instead of a finished, polished product.
High Performance for a Low Cost
One of the nicest parts of using a local environment is that you don’t need an internet connection to use it.
Lack of dependence on the internet means that most options run extremely quickly and extremely well. You can also view changes immediately in your browser which also increases the efficiency of the process.
Using a local environment also increases your security because the server is wholly contained on your computer. This deters hackers from breaking into your site through a live server.
A WordPress local environment is less vulnerable to hackers since there’s one less point of entry as your site isn’t on a live server.
Although, you should install an antivirus software on your computer to prevent attacks through your internet connection. Failing that, turning off your internet connection during development is also helpful.
Lastly, WordPress local environments are also cost-effective: many of the most popular software are free.
When Not to Use a Local Environment
Local environments are an excellent idea for all WordPress development. But, there are times when a staging environment might be a better option.
A staging environment is installed on a live server with restricted access to the general public. It’s more accessible than a local environment and can be testing in a real hosting environment with easy deployment to a production site.
Here are a few elements to consider when thinking about staging vs local environments:
- Does your site need a high level of security at the request of a client?
- Does your site have dynamic content that requires an internet connection to function such as an embedded twitter feed or a contact form?
- Is your site so large that transferring it between a live to local environment would prove extremely troublesome and slow?
- Are you able to recreate the demands of an extremely active site and anticipate all issues that could arise from activity?
- Do you need to test caching capabilities that otherwise prevents you from viewing changes?
Local environments are wonderful for developing and testing your own themes and plugins. It’s also great for keeping sites away from clients during the development, and testing phases. But, if you’re dealing with a more complex configuration, consider a live staging environment instead.
Local Development Configurations
There are multiple ways to set up a local environment on a computer. Choosing the best fit depends on your experience level as well as how much configuration you want.
The collection of software that powers the virtual server on your computer is called a server stack. The software necessary in whatever server stack you choose is PHP and MySQL (or MariaDB).
Apache is an open source web server software that bridges the gap between PHP and web browsers. It’s also commonly bundled with PHP and MySQL.
The combination of these are the letters you often see in association with a WordPress local environment such as MAMP or XAMPP.
Many local development software bundle the server stack into a single package. You can also download them from the internet for free or upgrade to a pro version with more features.
They’re also pretty simple to install and control with intuitive interfaces.
However, if you’re looking to change the operating system or isolate the environment completely from your computer, a local server may not be for you.
Different local server software runs on different operating systems. So, not all software will work the same on Mac or Windows.
Virtual Development Environment
Another option for WordPress local development is a virtual environment which runs with the help of a virtual machine.
A virtual machine is an emulation of a computer system that exists in a physical computer. But, it’s sandboxed from the rest of the system so the software can’t escape and affect the host computer.
Some of the benefits of a virtual machine are that you can run multiple environments at the same time as well as multiple different operating systems on the same physical computer.
Varying Vagrant Vagrants, also known as VVV, uses the Vagrant virtual machine environment tool in a specifically WordPress-oriented manner.
For example, VVV offers tools like WP-CLI, PHP Code Sniffer and Composer to mimic a WordPress production environment as much as possible.
There are also other WordPress-compatible virtual environments such as Bitnami, but the WordPress.org official recommendation is Varying Vagrant Vagrants, along with the WordPress Meta Environment addon.
A virtual environment is great for instances where you want ultimate configuration power. But, it does require some command line knowledge and technical know-how. It’s also useful if you’re working on other projects that don’t involve WordPress.
The Bottom Line
Taking some time to set up a WordPress local environment can make your whole development process easier in the long run.
It’s not only a more efficient workflow, but it’s also safer when it comes to your security and the performance of your website.
Do you plan on creating a local or virtual environment for your WordPress site? What do you consider to be your greatest reason for wanting to set one up? Feel free to share your thoughts in the comments below.