Generally, it’s highly recommended that you avoid modifying PHP files on a live server. If you make any kind of syntactical error, you run the risk of interrupting the functioning of your entire website and being left with the White Screen of Death.
If you’re working on a staging site, it might be acceptable to make minor modifications to your theme’s CSS on the live server, but this should never be done on a live (production) site.
The best way to develop a custom WordPress theme is to do so in a Local Development Environment. A local development environment mimics the function of a web server, but is only accessible locally on your own computer. Most local development environments include a PHP processor and a mySQL server, so you can install a Content Management System (such as WordPress) locally on your machine and develop a custom WordPress theme from there.
The benefits of developing locally are:
- Not relying on a remote server speeds up your development process. You won’t need to wait for the remote server to respond every time you reload the page to see changes. Page loads on a local development environment are much faster.
- You can work on your WordPress theme without an internet connection. Your local development environment doesn’t need an internet connection to function.
- You won’t need to use an FTP client to dig yourself out of the White Screen of Death. Any modifications that you make that trigger a PHP error can be easily fixed by opening that PHP file in a text editor and fixing any errors.
There are many different options available to use when setting up a local development environment, including MAMP, XAMPP, WAMP, DesktopServer, and Vagrant. Today, we’re going to talk about MAMP and DesktopServer.
For both of the programs, you need to have Administrator privileges on your computer for them to work. You won’t be able to start the Apache/mySQL servers without these permissions, so installing either of these applications on a public/lab computer won’t work.
Traditionally, MAMP has been one of the more popular options for local WordPress development for designers. Originally, it was one of the only options available for Mac, and it’s user-friendly interface meant you didn’t need to use the Terminal/Command Line to get things rolling.
Using MAMP with WordPress requires that you use WordPress’ famous “5 Minute Install,” which includes creating a mySQL database in phpMyAdmin, downloading the core WordPress files, and modifying a few lines in the wp-config-sample.php file.
The WordPress Codex has a detailed tutorial on how to set up MAMP and install a local WordPress installation on your computer here:
You can change the default folder for storing your local site files in the MAMP Preferences:
A more recent addition to the local development environment market, DesktopServer enables one-click installation of WordPress and requires very minimal configuration.
Below, you can see a screencast of the process of creating a new local WordPress installation:
Be sure to give your site a unique URL. Here we used www.samplesite.dev. The .dev TLD is added automatically to avoid confusion between development and production sites.
Migrating Files between Production/Staging and Development Environments
If you’re working on a custom WordPress theme or Genesis child theme, to move your theme from your local development environment to a live server (or vice-versa), you can simply use an FTP Client (like FileZilla) and upload the theme folder (in our case, it is ‘genesis-sample’):
If you’ve uploaded any media files, you’ll want to transfer your uploads folder as well:
Migrating WordPress Content
There are quite a few premium (AKA paid) options for migrating entire WordPress databases, the most popular of which is likely WP Migrate DB Pro. You can also use the built-in WordPress Import/Export tools to migrate your site content:
You’ll then need to run a URL updater to update any local URLs and image references, such a Velvet Blues Update URLs: