I’ve recently bought a Macbook Pro 13″ for development when I’m not sitting at my desk. This is my first experience with Apple and till now I’m delighted with my Macbook.
Since I still use Windows on my desktop system, one of the first things I needed to do was to find a way to sync my desktop environment with my mobile (Macbook) environment. This means that if, say, I’m developing a plugin at my desktop (Windows), then want to head over to continue work at a nearby coffee shop, I can grab my Macbook and continue development there painlessly.
Since I know there are others who have a similar setup, such as plugin developer Pippin Williamson, I’m going to outline the steps to get your Windows and Mac systems synced for WordPress development. I guess it will be useful for those of you out there who want to attempt something like this.
I will not be attempting to sync databases, because there doesn’t seem to be any reliable way to do this, and any solution I found also had considerable challenges which actually put me off even trying to implement DB syncing. The best thing to do with databases is to simply keep different databases, or else export and import when required. I would have loved to be able to sync everything, but I wanted the process to be easy and no straightforward solution could be found really.
So here we go, we only have 3 steps to have our Windows and Mac environments synced together for development:
Step 1: Have MAMP and XAMPP Set up and Running
I’m going to assume that you have already set up MAMP on your Mac and XAMPP on your Windows system. There are many guides out there on how to do this, and it’s pretty straightforward.
Test the setup in your browser by typing http://localhost.
Works? Brilliant, move on to the next step…
Step 2: Download and Install Dropbox
We will be syncing files using Dropbox, so go ahead and install it on both your Mac and Windows systems.
Haven’t used Dropbox yet? It’s an amazing file sharing/syncing application with a web interface to boot. Read more about Dropbox in Appstorm’s review, this is one tool you can’t afford to miss. Create one Dropbox account and make sure both your Mac and Windows Dropbox installations are using the same credentials and are working fine, then head over to the next step.
Step 3: Moving the htdocs Folder
Here’s where things get interesting. The idea is that we will be sharing the htdocs folder used by XAMPP and MAMP via Dropbox. Thus whenever changes are done while working on Windows, they are automatically propagated to your Mac, and vice versa. Naturally, we are assuming that both systems will be connected to the internet for this to work. As an added bonus, you will also get a third backup copy of your files stored on the Dropbox servers.
On Windows, there is a command that will enable you to make a link from your XAMPP folder to the htdocs folder within Dropbox. This command is mklink, and this is the syntax format:
[php]mklink /J X:\Path\to\hardlink Y:\folder\link\points\to[/php]
So in our case, just go to Start > type ‘cmd’.
Now cut your htdocs folder from the XAMPP folder and paste it into your Dropbox folder. It’s a good idea to backup the whole XAMPP folder before in case something goes wrong. You should have been backing up things anyway prior to this operation, always a good idea to backup your development folder.
Then with your command prompt open, enter the mklink command. That will probably look similar to this:
[php]mklink /J D:\xampp\htdocs C:\Users\username\Documents\My Dropbox\htdocs[/php]
Congratulations, you’ve just created a junction point. This means that when XAMPP goes looking for the htdocs folder it will be redirected to the folder within Dropbox. Everything works as before as all this happens virtually. It’s a very neat solution.
On Mac the process is easier, as you can easily change the location of the htdocs folder.
Within the settings of MAMP Pro (or MAMP), head over to the Apache section and select the Dropbox htdocs folder as your document root. Restart the server and you’re done.
Have you achieved the same thing using a different method? Let us know in the comments section below, we’re always on the lookout for better ways of achieving a goal.
If you enjoyed this post, make sure to subscribe to WPMayor’s RSS feed.