My local WordPress development environment is where I work on new websites, develop plugins and themes, and test changes and updates to existing websites before they go live. Before I give you an overview of my setup, I’ll briefly answer these questions which I have posed to members of the WordPress Portsmouth Meetup.
Questions regarding local development environments
Do you run local and/or staging copies of your live sites?
Yes. I run local copies.
Do you regularly backup your live sites and restore them to other environments?
Yes, I regularly backup the live sites. But I only restore them to my local development environment when I need to make significant changes or work with the latest content.
Do you develop enhancements to your sites in these environments?
I develop all my enhancements in one or more local installations.
Do you maintain the production environment and development environment and keep the content reconciled?
Overview of my setup
Here’s an overview of my setup.
What’s your setup?
- For my local development I run a custom WAMP stack on my Windows laptop.
- I develop my code in PhpStorm, but also use other tools.
- I use Git version control with my repositories ( public and private ) in GitHub. See Version control
- I have multiple local installations of WordPress, in subdirectories of DocumentRoot.
- Some installations are WordPress Multi Site; both subdomain and subdirectory versions.
- I use custom domains and subdomains and connect using https with self certified SSL certificates.
- Most of my plugins and themes are symlinked.
- I export and import MySQL databases using phpMyAdmin.
- I backup files from live sites using the hosting company’s facilities.
- My live sites are hosted on SiteGround Cloud Hosting.
What do you use it for?
- I develop WordPress plugins and themes.
- I build and/or maintain some sites for customers and family members.
- I build and maintain my own sites; quite a few.
- I sometimes debug problems with WordPress core, plugins and themes.
- And may raise issues if I think it’s worthwhile.
- I don’t often raise PR’s to fix the problems.
- When reconciling content between local and live sites I may
- either clone content, post by post, using my own plugin
- or export/import a complete backup
- or apply a mixture of methods
What tools do you use?
How do you do these tasks…
backup/export, restore/import, reconcile, develop, test, debug, release?
- Export the database using phpMyAdmin.
- Archive all files in
- Import the database using phpMyAdmin
- Manually set
- Switch to local URLs using better-search-replace
- Unzip required files from the archive of
I use my own plugin called oik-clone to reconcile content by pushing and/or pulling content between the local site and the live site(s).
Develop, test, debug, release
- I develop my code using PhpStorm.
- Plugins that deliver blocks are built with
- I’ve installed
wp-envin order to attempt to build Gutenberg, but not yet been successful with it.
- I debug the PHP code locally using oik-bwtrace in preference to Xdebug
- Sometimes I write PHPUnit test cases.
- If I have them, I run them.
- I package my plugins and themes using custom scripts
- including automatic translation into UK English and the bbboing language.
- And deliver them:
- using GitHub if you want the source code,
- from oik-plugins.com for free plugins or themes
- from wordpress.org by updating the SVN repository from the Git repo
Why would you recommend your solution to others?
I would recommend using a local development environment:
- to anyone who has bespoke code they need to manage
- for people who have complex content updates, especially if the changes need to be reviewed by others
- to people whose business depends on the website operating correctly; eg ecommerce sites, event sites
I wouldn’t suggest attempting to copy my environment verbatim.
- My particular environment was cobbled together over a period of years.
- It has some limitations.
- I imagine that some of the more modern tools might be better for new starters.
What are the pros and cons?
Pro – In situ PHPUnit testing
Pro – I don’t have to start up virtual environments.
Pro – I use self certified SSL certificates
Con – An accidentally run WordPress update can completely destroy a plugin’s Git repo.
Con – I can’t easily run multiple versions of PHP
Con – Uploaded image size versions are sometimes inaccessible.
Find out more looking at these pages.
- WordPress plugins
- Local development
- Server environments
- Development hardware
- WAMP configuration
- Tools and languages
- Version control
- What’s not in my development environment?
- Anything else in your development toolkit?