PHP Preview in BBEdit
I do almost all my work in BBEdit, because I use a remote server on which to test my PHP. But I’ve been using HyperEdit for almost everything else, including mocking up CSS, working with JavaScript, and cranking out non-work PHP. This is completely because of HyperEdit’s integrated PHP preview. I can code in the left pane, and instantly see my code in the right pane without switching to a browser. However, I find that text editing gets slower the more code you type, and the developer hasn’t really released an update in a while. That’s not his fault, I think he’s in school. But the fact remains that I like BBEdit better for sheer text editing polish.
BBEdit has a previewing feature, too, but it takes a little finagling to get it to parse PHP code. I finally figured out how to do it. First, make sure Personal Web Sharing is enabled, and then put this code in a file named BBEditPHPPreview.php in your ~/Sites/ directory:
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
include $_GET['file'];
?>
Then, set up a site in BBEdit’s HTML Web Sites preference pane to look like this (substituting your own username for ‘dbergey’, of course):
One caveat is that the file you’re editing has to exist on disk in one form or another. BBEdit’s good about creating and rendering files with unsaved changes, but not completely new and as-of-yet unsaved files.
It’s not a complete replacement for HyperEdit’s two-paned approach, but with my Butler/AppleScript window-resizing hotkeys, I doubt it will be such a big issue for me.
My one niggling issue is that the preview doesn’t update instantly, like HyperEdit’s did. I haven’t found any way to remove BBEdit’s ~2 second updating delay. I even checked out the Help menu’s “Secret Preferences” item. How cool is that name, anyway?