Today I wanted to share a repository I found on the internet that helps to configure WordPress to work with multiple environments.
I’m using the repository without trouble, it’s really easy to use, just follow the instructions in the readme.
If you want to understand in more popular words what it does, I tell you. Let’s say you have your local environment and a test environment hosted in the public server, but hidden in a private section and a live instance in the same place. The first two instances would have the WP_DEBUG value probably set to true while in the last environment it’ll be switched off (false). Also, the DB connection settings are different for each instance, so here is where this repository will help you. It’ll separate the main WordPress config file in different files that will be loaded upon environment.
There are 2 different ways to configure the environments, you can set a variable in the vhosts file when you declare your virtual host or base the environment on the URL. I use the last approach, because I feel more comfortable and I think it’s easier to maintain.
As an example, you’d probably have the following URL structure in your site:
mysite.local – Local environment
mysite.dev – Test environment
mysite.com – Production/Live environment
Ok, that’s it, hope it helps.