WordPress development has grown exponentially in popularity. This is in large part because the platform itself is free and is extremely easy to customize. When starting a new WordPress development, you are presented with 3 options for doing your development. You can do it on the live site (not a good idea), you can set up a staging environment or you can set up a local environment. In this article, I show you how to setup a local WordPress development environment.
Having a solid local WordPress development environment will help with your workflow and will provide you with a stress-free environment to code. Let’s have a look at what a local WordPress environment is, why they are beneficial and how to set one up.
What is a Local WordPress Development Environment?
A local WordPress development environment involves setting up a server environment on your local machine. Rather than using a server provided by a hosting company, all development is done locally on your own machine. This allows you to customize your site without the fear that it will break, and make all kinds of changes, before pushing your site online. The helps eliminate any risk when building your site and can make the development process much less stressful.
Even though you’re not working on your site live, your site will look like it’s live in your browser. Your browser will simply be referencing the files stored locally on your computer, but no one else will be able to access or view your site.
To setup a local development environment you’ll need a few additional tools (which I will get into below).
Why Use a Local WordPress Development Environment?
One major advantage of a local wordpress development environment for your site is that you can work on your site without being connected to the internet. If you have slow wifi or you’re traveling, you can continue to work without having to endlessly search for a wifi signal.
Your site will also be secure and free from prying eyes until you’ve actually completed the project. You won’t run into any server performance issues or spend endless time waiting for your site to refresh. The performance of your site will simply depend upon your local machine.
A local WordPress development environment will allow you to maintain high levels of security while testing your site and let you ensure there are no bugs or fixes that require your attention.
However, if you do need to show progress on a site you’re building, then you may want to opt for a staging environment, which allows you to host your site on a live server, while it’s still shielded from the general web.
This gives you more flexibility in showcasing your work, while still being able to access your site from any computer or location and improving the security.
The Steps to Setting Up a Local WordPress Development Environment
If you’re sold on creating your own local WordPress development environment, then you’ll need a few tools to help you get started. There is no perfect solution for setting up your local environment, so it’s important to choose the tools that are the best fit for your needs.
1. Choose a local server environment. Using the right tools will speed up the time it takes to setup your local development environment. There are numerous options to choose from, but the tools below are the easiest and most commonly used:
MAMP will give you a complete local environment for developing your WordPress site. This solution will bundle everything you need to get your server up and running together, so you don’t have to bring multiple tools together. It’s available for both Mac and Windows.
XAMPP is a great open source tool that’ll work across Mac, Linux, and Windows machines. Plus, it’s one of the easier options to setup and use. Once you’ve installed the tool you can quickly install the WordPress software stack, which will allow you to start building your WordPress site immediately.
2. Pick a text editor. If you’re an experienced developer, then you probably already have a preferred text editing tool to edit your code. But, if not, then you’ll want to find a solid text editor.
A text editor that’s built for developers will help to increase your programming efficiency and avoid making errors in your work.
Some commonly used solutions that are geared towards WordPress development include:
- PhpStorm – This editor supports WordPress development right out of the box, and will atomically detect if you’re building a site in WordPress.
- Atom – This is a relatively new open source editor that easy to use, has an active community, and has a number of WordPress-specific add-ons.
- NetBeans – This is a full-function editor that’s been around since the 90s. It includes impressive features like a built-in debugger and numerous WordPress add-ons.
- Sublime Text – This editor is very lightweight, fast, and a pleasure to use, while coming equipped with WordPress development add-ons.
- Coda – This is a Mac-only editor that’s very lightweight and includes WordPress-specific plugins.
- Install the right tools and plugins. Before you start building your site you’ll want to enable WordPress debugging features. This will allow you to find any glaring errors or bugs and fix them before you push your site live.
To enable debugging you’ll need to locate your wp-config.php file and add the following piece of code (which will turn on the debugging feature):
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_DISPLAY', false );
define( 'WP_DEBUG_LOG', true );
You can also install a plugin like Log Viewer, which will allow you to view and clear your debug log.
Other tools and plugins you might want to install include WP-CLI, which will streamline the development experience or Query Monitor, which acts as a comprehensive debugging plugin.
3. Start building your site. With your local development environment created, WordPress installed, and the right tools and plugins active it’s now time to start building your site.
If you’re building a site from scratch then you’re ready to go. However, if you’re making changes to an existing site, then you can use a cloning tool to create a copy of your site you can then begin customizing.
Setting up a local WordPress development environment might seem like a lot of work, but developing a site on your local machine can become a crucial part of your development workflow. It’ll not only make you more efficient, but you’ll be able to build a site without the worry that you will break something.
There are many approaches to setting up a local WordPress development environment. The one contained herein is just a suggested approach. What you do will largely depend upon the operating system your local machine uses. Do some research before you get started and you will find the best solution for you.