WordPress has a lot for those who love developing their website from scratch. The tools and built-in functionalities available in the core WordPress makes it easy for developers to setup a site, install a theme and plugin in a robust WordPress development environment.
However, setting up a WordPress development environment in a local server is a lengthy process, but you can segregate the stages to make your work easier and efficacious. Here, in this post, we will how to setup the WordPress development environment using three different stages.
Let’s get started
Selection of a Server
You can’t overlook this step especially when it comes to setting up the WordPress development environment. A selection of a good server can help you achieve your targeted goals with ease.
Since there are hundreds of options available on the web, make sure you pick the right one to host your WordPress site on the local environment.
Time for some serious work in the Development Stage
The development stage is all about creating a WordPress site in a local host – a web server that is running in a computer system. In case you are using OS X, then you can instantly set up the environment with MAMP. As a Window’s user, you will get a ton of advanced options such as MAMP, WAMP, etc – a good way to start off your development process.
Under this stage, you can use the development tools like Grunt or Gulp or CodeKit to develop a well-coded and well-structured WordPress site. You can do some experiments; write WordPress code, build websites, plugins, and themes in a very effective and efficient manner.
Don’t forget to enable the WP_DEBUG into your WordPress site to track all the errors you have been making while coding your site. You can install the plugins like RTL Tester and Query Monitor to help you see debugging and performance information related to database queries.
To enable the WP_DEBUG, access the wp-config.php, and add the following line of code:
define ( ‘WP_DEBUG’ , true);
define (‘WPLT_SERVER’, ‘dev’);
This means you are marking your WordPress install in localhost as “development” by showing you the Server as DEV SERVER. This setting enables the “Discourage search engines from indexing this site” option to stop search engines from indexing your site – as it is in the development mode.
You may also need to deactivate some of the WordPress plugins that are not required in the development phase. Some of these plugins such as caching, Akismet, and backup. To deactivate it, you’ll need to specify each plugin in an array with WPLT_Disabled_PLUGINS.
This will deactivate all the plugins that you don’t want during the development stage.
Staging Stage: Throughly Test your Site
This is one of the most crucial stages where we test our site. So, make sure that your site should be in such an environment that closely resembles the live site (such as the server specification, the content) to let to detect errors and bugs quickly and easily.
In this stage, you will need to consider all the aspects and identify all the bugs and fix them as soon as possible. In fact, it is better you set you staging site in a subdomain, such as staging.mysite.com or you can also set it in a separate domain like mysitestaging.com.
Even, you can deactivate those plugins that you’ve used during the development stage. But make sure you don’t deactivate all the plugins used in the development phase. Keep some of the development plugins and WP_DEBUG enabled to detect more bugs while testing your site on the staging server.
Final Stage: Get, SET, Ready & Go
This is the final stage where we transfer our WordPress website to the live server and make it accessible for all the web audiences. As it is the last phase of WordPress development, make sure you deactivate all the plugins used in the development stage and activate the plugins that you deactivated (such as caching, backup, etc). You can also disable the “WP_DEBUG” option as you are done with all the testing.
So, below is the coding that will help you achieve the above things:
In order to keep the testing server database upgraded with the fresh content, ensure that you get new content in the live server. This will make your testing more precise and give you an idea about how your content displayed on your live server. To achieve that, you can add this line in the live server wp-config.php:
After that, you will start receiving notification via email whenever your client adds new content in the live server. Whenever they add the new posts and pages, you can immediately copy the content database from the server.
In case, both your testing and live server is being hosted in the same server, then you should access your phpMyAdmin → Select the Wp_posts database → operations tab → select the staging site database (within the copy table to database.table box) → click on the Add DROP TABLE option to overwrite the existing database.
Don’t forget to save the changes. Now you have well-organized WordPress development environment stages for your web project.
This is the simplest way to manage the stages for developing a professional-looking WordPress site. In the similar way, you can setup/install your WordPress themes and plugins in the same development environment. If you have your own workflow, then freely share with us.