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:
- Open up the Bundle Editor by hitting Ctrl+Option+Apple+B or opening the Bundles menu and selecting Bundle Editor > Show Bundle Editor.
- Find the PHP bundle in the list on the left and open it up.
- Select the ‘Validate Syntax’ command and then change it’s ‘Save’ option to ‘Current File’ in the dropdown on the right.
- Change the keyboard shortcut to Apple+S (or whatever you use to save) in the lower right. Your settings should now look like this.
- 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!
Update (2008-5-23)
You can prevent the tooltip from displaying when there are no syntax errors by changing the command to: