[TxMt] PHP Bundle Validate Syntax

Sven Axelsson sven.axelsson at gmail.com
Sun Sep 30 10:26:28 UTC 2007

Having upped my PHP version to 5.2.4 I realized that the Validate
syntax command in the Textmate PHP bundle gets text from both stdout
and stderr. Don't know if it was like that with previous PHP version,
but the fix is simple.

change result = `#{ENV['TM_PHP'] || 'php'} -d display_errors=on -l`
to result = `#{ENV['TM_PHP'] || 'php'} -d display_errors=on -l 2> /dev/null`
in the Validate syntax command

I also found it useful to add a similar command for ZendCodeAnalyzer.
Create a new command with Save: Current document, Input: Entire
document, and Output: Show as tool tip containing this code:

#!/usr/bin/env ruby
require ENV['TM_SUPPORT_PATH'] + '/lib/textmate'
result = `#{ENV['TM_ZCA'] || 'ZendCodeAnalyzer'} #{ENV['TM_FILEPATH']} 2>&1`
puts result.gsub(/^.*\(line (\d+)\)/, 'line \1')
TextMate.go_to :line => $1 if result =~ /line (\d+)/

In this case we do want both stderr and stdout, but they are in the
wrong order, so 2>&1 fixes that.

Perhaps this is useful for someone.

Sven Axelsson

More information about the textmate mailing list