In web development, it's commonly known as a best practice to work within multiple environments. While the number of different environments and usages may vary, it's common to see 3 different environments: development, staging, and production.
Within this article, you'll learn about how different environments work and how to configure them.
Development environments are a core part of maintaining a healthy WordPress site. Most of the time, these environments live locally on a developer's machine, although depending on the site's needs, they might exist elsewhere.
The reason for using a development environment is simple: it allows you and your team to implement changes and test things out without the risk of breaking your live site.
Not only do development environments make your site more stable, but they also have the added benefit of making development far easier. Utilizing tools such as XDebug allow you to track down issues much more efficiently.
In general, you'll want to have a few different things configured:
Before pushing your development code to production, it's a good idea to test it in an environment that best matches where your code will live permanently. This is where a staging environment becomes into play.
Since your staging environment should match your production environment, you'll want to make sure that things like caching and CDNs are enabled. Of course, since your staging environment isn't publicly accessible, leaving things like error logging and debugging turned on are perfectly fine. In fact, it's generally a good idea to turn them on in staging too, just to make sure there aren't any errors that you missed.
When working with a staging environment, your workflow will look something like this:
- Make changes to your site within a development environment.
- Once satisfied, push your changes to your staging environment.
- Clear any caches and CDN on your staging environment to ensure that there isn't any stale data still there.
- Thoroughly check over your staging site, making sure that everything is as expected. Ideally, make sure that content delivered from your cache and CDN are working properly as well.
- If everything is looking good, push your changes to production.
Once everything looks great inside your staging environment, it'll be time to push your changes to production.
Your production environment should only contain a stable, tested copy of your site at all times. If not, your site's reliability has the potential to suffer.
Unless absolutely necessary, your production environment's configuration will look like this:
- Debugging and error display turned off.
- Caching enabled.
- CDN enabled.
Setting Up and Syncing Multiple Environments
To create development and staging environments within your Pagely account, the simplest method is to create additional apps, then use the Pagely Sync tool to copy the data from your production app.
As for local development environments, the choice largely depends on your preference. Here are a few that we recommend:
If you're regularly syncing content across Pagely environments, you may benefit from the Pagely Clone tool, which gives you much more customization that Pagely Sync. Our team will be happy to help you set it up.