What is Subversion?

If you’re new to WordPress or software development, you might be wondering, “What the heck is Subversion?”

You’re not alone. It took me a while to figure it out. Simply put, Subversion (or SVN for short) is a version control system for software. It tracks all your changes and is especially helpful if you have multiple people working on the same project.

With the popularity of GitHub, Git has overtaken Subversion as the most popular version control system, but many open source projects are still using Subversion, notably WordPress.org.

So if you want to create themes or plugins for the WordPress.org repository or contribute updates to the core, you’ll need a basic understanding of Subversion. If you’re working with WordPress, this page has the basic instructions: How to Use Subversion

Using Subversion to Update Plugins

I just updated my WordPress running log plugin that I haven’t updated in over two years. Better late than never…

I’m on a new laptop now, so I had to rediscover SVN.

After relearning Subversion for an hour, here’s my advice: don’t make Subversion harder than it has to be. If you are the sole editor of a plugin, you don’t need a subversion client. They make things too complicated. I tried Dreamweaver, Coda, and others, and they all make the process too complicated. I’m not collaborating with other programmers, so I don’t need all the extra features. The simplest way to update your WordPress plugins is to use OS X Terminal (or Command line on Windows). I’m no Terminal pro, but I was able to quickly update my plugin, without any extra hassles. Here’s how:

1. If you have Xcode it’s easy to install Subversion. Go to Xcode Preferences -> Downloads and then click Install on Command Line Tools
2. Now create a folder for your plugin
3. Now open OS X Terminal and change directory to your new folder. Something like this cd users/kevin/dropbox/plugin
4. Using Terminal, download the existing plugin from the repository by typing: svn co http://plugins.svn.wordpress.org/plugin-name

  • The “co” stands for check out
  • Change plugin-name to the name of our plugin
  • The plugin files will download into your current folder

7. Use your favorite text editor to edit the files as needed. Don’t forget to update the readme.txt file
8. Upload the changes to the repository by typing: svn ci -m “update notes”

  • The “ci” stands for check in
  • Change “update notes” to your notes

Local WordPress Development on Multiple Machines

Working with WordPress on a local machine can be frustrating if you frequently use more than one computer.

I’ve seen a few blog posts where developers will set up two MAMP instances and then sync their database files with Dropbox so they can access the same database file on both machines. This is tricky to set up and can easily lead to corrupted database files.

Instead of using the MAMP provided local database, I use a database on my web host account and store all the WordPress files in DropBox. Here are the steps:

Setup

  1. Install MAMP on both machines.
  2. Once MAMP is set up, go to MAMP Preferences -> Apache and change document root to your Dropbox folder or a Dropbox subfolder. For me it’s: /Users/Kevin/Dropbox
  3. Ensure you change this setting on both machines
  4. Now create a database on your hosting account (I currently use Namecheap hosting).
  5. Be sure to enable remote access to MySQL. If you’re using a shared hosting account and cPanel, click on Remote MySQL

WordPress Installation

  1. Download WordPress and unzip it
  2. Place the unzipped WordPress folder in your Dropbox folder
  3. Start MAMP
  4. Go to: http://localhost:8888/ (This may be different if you changed your default MAMP port settings)
  5. Click on the WordPress folder
  6. You should get the following WordPress wpconfig.php setup screen:

    create wp-config.php file
    Create WordPress wp-config.php file
  7. Now create the wpconfig.php file. The tricky part is figuring out the correct credentials for remote login to your hosted server. Here is an example if you’re using BlueHost:

    Remote database settings
    Remote database settings
  8. If you’re using a shared hosting account, you may need to prefix your database name and username with your username. When you create your database and users from your cPanel, you should see something like: username_databasename. For example: kcm_wp1
    Your username would then be something like: kcm_user1
    And you may need to use an IP address in the Database Host field.

The only downside to this arrangement is that it’s not quite as fast as a local database.

It’s really good practice to install multiple instances of WordPress on your local machine using different scenarios. It makes the real life installation second nature.