TextMate and PHP: automatic syntax checking when saving
One of the cool things about the TextMateJavaScript Tools is that it binds Quick Lint to âS, producing a tooltip warning any time you save a file with invalid JavaScript. I like this behaviour and wanted to add it for PHP as well - this version also strips trailing whitespace from valid files:
Download: Save and Validate.tmCommand
Here's the source:
#!/usr/bin/env ruby requireENV['TM_SUPPORT_PATH'] +'/lib/textmate' result =`ENV['TM_PHP'] ||'php' -l ENV['TM_FILEPATH']`if result =~/line (d+)/ puts result TextMate.go_to :line =>$1 else system("perl -p -i -e 's/[\t ]+$//' ENV['TM_FILEPATH']") system("osascript -e 'tell application "SystemUIServer" to activate' -e 'tell application "TextMate" to activate'")end
To install, open the PHP Bundle in the Bundle Editor, add a new command with the options Save: Current File, Input: None, Output: Show as Tool Tip, Key Equivalent: âS and the Scope Selector: source.php.


blog comments powered by Disqus