powdahound's lodge
TextMate tip: Validate PHP syntax when saving

The JavaScript Tools bundle for TextMate automatically runs JavaScript Lint on your files when saving and shows a little tooltip if there are any errors (like the missing semicolon below).

It’s very easy to enable similar functionality for PHP files. The default TextMate PHP bundle already comes with a ‘Validate Syntax’ command but it’s bound to Ctrl Shift V. Here’s what you need to change:

  1. Open up the Bundle Editor by hitting Ctrl Option Apple B or opening the Bundles menu and selecting Bundle Editor > Show Bundle Editor.
  2. Find the PHP bundle in the list on the left and open it up.
  3. Select the ‘Validate Syntax’ command and then change it’s ‘Save’ option to ‘Current File’ in the dropdown on the right.
  4. Change the keyboard shortcut to Apple S (or whatever you use to save) in the lower right. Your settings should now look like this.
  5. Close the Bundle Editor (it saves your changes automatically).

Below is an example of what you’ll see when saving. It will even move your cursor to the line with the error!

blog comments powered by Disqus