With the ever-increasing popularity of WordPress, many developers find themselves working on larger sites that require a lot of maintenance work. Working directly off of the live site for maintenance work is a terrible idea for these larger sites, or even smaller sites for that matter. If you’ve stumbled across this article, it’s likely that you’re guilty of this and you’re in need of a better workflow. So let’s get started!
Local, Staging, Live
Every website you work on should at a minimum have a local version, staging version (for client review and QA), and a live version. The work that you do should flow throw these variants in sequence as you progress through the development cycle of your project. Everything from adding a new widget to redesigning the entire site should be done in this order.
Local WordPress Development
In the past, many developers have opted for a command line version of local development using tools like Vagrant, VVV, or XAMPP. While these are effective tools for local WordPress development, I find myself gravitating more toward actual user interfaces to accomplish the same job. That’s where Local by Flywheel comes into play. Local allows you to create WordPress installations directly on your computer with just a few clicks. You can even back up your live WordPress site and drag it into the Local window to get started with an exact copy. If you’re a Flywheel customer, you can even push and pull your entire website in one click. Pretty simple.
Once you’ve got a working local copy of your WordPress site, it’s time to get to work. Custom PHP modifications have just become very easy for you. With a local site, you’re able to modify the theme files and see the changes in real-time without having to deploy through Git or send them back to the server via FTP. Instead you’ll have the ability to test everything right there on your local URL.
So why the extra effort if you’re only changing something in the WordPress dashboard? Well for starters, you’ll never run into the issue of breaking your live site with a bad modification since your local site runs completely independently from your live site. You can break it as many times as you want and you won’t have to panic of what you’ve done. Just get in there and find out what went wrong. Viewers of your website will never notice anything has changed until the fully tested version has been deployed.
Push it to Staging
Staging sites are the middle point between local & live. It’s where you will make sure that your changes play nice with your website’s server and show the changes to your client before pushing them live. For this reason, it’s important to make sure that your staging site is located on the same server as your live site. Differences in the server environment between staging and live can cause you to run into unanticipated issues. For example, something that works on PHP 5 may not play so nice with PHP 7. The PHP version of your staging site should ALWAYS match that of your live site.
So how do you get your local changes to your staging site? There’s many ways. Often times developers will create a full backup of the local site and import it into the staging server. I prefer to do it in pieces.
Plugins are typically third party and therefore don’t require any version control on your end. For this reason, I choose to push all new plugins to the staging site with FTP. While those are taking their time uploading, I can freely move on to the next steps.
If you’re working with a custom WordPress theme, you should be tracking changes using Git. Using a tool like DeployHQ, you can easily deploy changes from your Github/Bitbucket repository to both your staging site and your live site.
If you’re using a third party theme, you shouldn’t be modifying the core files of the theme, so just toss that onto the staging server with FTP. If you’re making changes to a child theme, you can either use version control and a deployment method, or upload your modified child theme to the server with FTP.
Media Files & Database
Wondering why I grouped these together? Easy. The plugin that I use for database migrations, Migrate DB Pro by Delicious Brains, also handles media files! Any modified media files can be pushed/pulled from one WordPress installation to another along-side the database with one click. Super easy!
Let’s Take it Live!
Once you’ve fully tested your changes on the staging site, it’s time to push everything live. Hosting providers that have built-in staging environments often have a one-click feature to make this happen. If you don’t have that option, repeat your process for migrating from local to staging, but this time do it from staging to live. Then you’re done!
Need some help with maintenance on your WordPress site? We’d love to hear how we can help out!