Dynamic local previews HOW-TO
Out on the wild and dusty untamed internets, I'm still seeing a lot of confusion regarding Coda and its ability to handle dynamic pages (such as those with PHP or SSIs) when previewing a file locally.
The simple fact is that, yes, dynamic local previews are possible, and today I'd like to show you how it's done.
A quick aside: What I'm about to describe requires 1.0.1 or later of Coda. (The most recent version as of this writing is 1.0.3.) This was not possible in Coda 1.0, and I think that may be the source of a lot of the confusion about Coda's capabilities.
(Also: This isn't the only possible Coda workflow! You can just as easily edit files directly on a remote server, or work locally only.)
The scenario
The scenario is that you have two copies of your site -- the live, production copy out on the internet (the "remote" copy), and a copy that lives on your Mac (the "local" copy).
Odds are, if you are working this way, you already have a locally installed web server with the same configuration as the remote production server. In my case, both copies are powered by Apache 2 with a custom-compiled PHP 5 module.
Compiling and/or configuring Apache and PHP is beyond the scope of this tutorial, and I'll assume you've already got this part working.
Configuring the site in Coda
With that set up, all you need to know are the local and remote paths to your web root, and the local and remote root URLs. Let's look at an actual working example:
Note the Root URL field, which contains the URL for the production copy, and the Local URL field, which contains the URL for the local dev copy.
The Remote and Local Root paths work the same way. In this case they happen to be the same on both copies, but this needn't always be the case.
Finally, the server information is configured for SFTP connections.
Now all I have to do is double-click on the Site to start working on it.
Workflow
Now that I've opened the Site, my local and remote file browser tabs show me the corresponding file trees, which are identical in this case. I've created a single file called index.php which has the same content in both the local and remote copies:
Note that I can switch either of these tabs to preview, and the remote file will preview relative to panic.com and the local file will preview relative to localhost. In both cases, the PHP is processed.
Now let's make a change to the local copy. I'll change "hello" to "goodbye" in the local copy only:
Now I'll preview the change:
Looks good.
Coda has noticed that I've changed the local file and has given me several options for uploading the changed file back to the server. I can either click the up arrow icon next to the individual file, or click Publish All, which will upload all changed files in one shot. I'll click Publish All.
Next, I'll switch back to my remote preview and click the Reload button.
Hooray, there's my change, live on the production server!
Summary
I hope this helps bust the most popular myth about Coda. Please help spread the word if you know someone who doesn't think Coda can do local previews of dynamic pages.





