GridPane WordPress sites utilise a wp-config.php file in a secure non public directory a level above your site root folder. If for any reason a user adds a wp-config.php file to the site htdocs directory, this will cause unpredictable behaviour with staging and may result in the corruption of a production sites database with staging data.
One of the cardinal rules of WordPress development is....
No Cowboy Coding!
Cowboy Coding, the deservedly maligned practice of making code edits to live WordPress sites is something every serious WordPress professional should avoid at all costs.
Yes, WordPress has code editors for themes and plugins, and yes it also has a checker for syntax and PHP errors now, and using those does have a place - making very very simple and quick edits.
A modern development workflow will use different development environments alongside the live production site - including, at the very least, a local production environment and a live staging environment. This is because it often makes sense to work locally, for speed and efficiency, but when you want to test your code and know it will work in production, or you need to show ongoing work to clients for feedback, you need a live environment. This is where the staging environment comes in to play..
Many plugins and platforms offer 'staging' environments, but for staging to be truly useful it shouldn't be hosted on a differing environment to your production site. Staging and Production should both share an exact hosting environment to ensure that your testing is sound.
GridPane provides exactly this.
With that being said, this article aims to run you through the easy to use GridPane staging workflow.
Step 1. Create a GridPane Site with a Staging Environment
When you create your primary site, make sure you also create a Staging Site by having the Staging Site Checkbox clicked.
We have an easy to follow guide taking through the steps to create a GridPane WordPress site here.
Once your staging sites have been created you can navigate to them via the Staging menu item in the top GridPane navigation menu.
You will see a list of all your staging sites in the Active Staging Sites panel.
Step 2. Configuring your Staging Site
GridPane Staging Sites are just as configurable as the production sites, and come with a similar Site Customizer, to open it click on the staging site url in the Active Staging Sites panel.
When the site customizer opens you will see a familiar range of options. Staging sites are identical in function to live sites to ensure that any testing done is sound.
When your sites are created they will have caching enabled, it is recommended that when you are working on your staging sites you disable caching and enable it to do your testing.
We also recommend that you enable an SSL for your staging site to more closely match your live environment, and use the HTTP authentication option to make access to view your staging site secure via password protection only.
With your staging environment ready, it's time to start using it.
You will need to make sure that you have an A record resolving to your server IP at your DNS, without this your staging site will not be accessible, unless you use a local hosts redirect.
Step 3. Clone Your Production Site into Staging
Whether or not this step is applicable will depend on the specific workflow for your project. It may be the case that you are working on an entirely new site and don't need to clone the production site, if that is the case then you can just skip ahead to Step 4.
If, however, you are working on the ongoing development of a live production site, then you should copy your live site into the GridPane staging environment as a first step.
For this article I have my production site featuring lots of Cats doing Kung Fu and other such stuff at my primary domain serious-wordpress.pro
When we created our site with staging sites clicked, GridPane also created an empty fresh WordPress install at staging.serious-wordpress.pro.
To push our Production site into the staging environment, return to the Active Staging Sites panel and locate the blue Live to Staging
Click the button to begin the push.
Select Database Tables to Push
GridPane allows you to selectively push only the database tables you require. If you want to push the entire database leave the checkbox unchecked and click Push Live to Staging to immediately begin the push.
If you don't want to push the entire database then click the checkbox provided.
You will be presented with a selection menu, all the database tables available to push are available on the left Source side. Select whichever tables you wish to push, and use the arrow buttons to move them into the Target side.
When you are satisfied, click Save to begin the push.
A popup modal will appear and update with each stage of the push.
When the push is complete and you visit your staging site, you will see that your production site files and database has been migrated in, the staging site is now a carbon copy of the production site.
Step 4. Working Locally
We have our production site copied into our staging environment, and now we need to move this to our local environment.
At GridPane we recommend that you develop locally, test in staging, and then push to live.
To do that we will need to take a copy of the staging site and work on it locally. There are two ways to do that effectively, using a version control system such as Git, or using migration plugins.
Git based local < > staging < > production workflow
In the near future, we will be fully integrating Git with staging to provide a complete development workflow, but for the time being if you want to incorporate Git into your local > staging > production workflow with GridPane, then please just reach out to us on intercom and we will be happy to help.
Plugin based local < > staging < > production workflow
Otherwise, the easiest route to copy your staging sites to local, and local sites to staging, is to use one of the many many WordPress plugins, two great examples are:
Now, you might be asking, why do you need to push from Live to Staging if you are just going to take a copy of staging for your local environment, and that is a very fair question, and has an opinionated answer...
You don't need to... but we recommend it, for a variety of reasons:
- Production WordPress sites should be as light as possible and not have any plugins on them that are not required for the functioning of the site, often migration plugins are left on sites even when not in use.
- The operation of migration/backup plugins is quite heavy and could negatively affect visitors to your site.
- Migration plugins often leave remnant files behind, and in some cases these files could pose a vulnerability, there is no need to take this risk.
But as is the way with GridPane, the choice is yours.
Local Environment Applications
In the WordPress ecosystem we are lucky to have a wealth of local environment applications to develop on, some specifically for WordPress, others more generally for PHP that work just as well, a few of the more famous include:
- Local by Flywheel
- MAMP Pro
- Desktop Server
- Varying Vagrant Vagrants
- Laravel Valet
- WPLib Box
Pick your weapon of choice to best suit your needs, and once you have completed your site locally, migrate your local development site back to the staging environment using whichever tool you are comfortable with.
Step 5. Test your Updated Site in Staging.
With your newly minted code in the staging environment you are able to safely test your code in a matching environment to the production site. This allows you to be certain that everything works properly before you take the new site live.
It also provides you the perfect environment to show the site to your clients as the work progresses.
During your testing, make sure to match the environment exactly to the production site, enable SSL and Caching as required.
Browse your site as a visitor and ensure that everything is working as it should.
Step 6. Push Staging to Live
Once you are satisfied that everything is working as expected, it is time to push your new site into production.
In the Active Staging Sites panel click the blue Staging to Live button this time.
Select the database tables you want to push, if any, and confirm the push by clicking the Push Staging to Live button on the pop up modal.
A popup modal will appear and update with each stage of the push.
Once completed the Active Staging Sites panel will update with a green success notification.
And you will be able to visit your brand new production site!
GridPane staging really is that easy to use.