Skip to content

Instantly share code, notes, and snippets.

@tuxtina
Created June 2, 2013 16:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuxtina/5694143 to your computer and use it in GitHub Desktop.
Save tuxtina/5694143 to your computer and use it in GitHub Desktop.
Quick & dirty PHP syntax check on save for use with TextWrangler. Put into ~/Library/ApplicationSupport/TextWrangler/Attachment Scripts/Document.scpt.
on documentDidSave(currentDoc)
set fileName to the name of the currentDoc as string
if ((offset of ".php" in fileName) > 1) then
set f to the file of the currentDoc
set filePath to the POSIX path of f
set lintOutput to do shell script "php -l \"" & filePath & "\"; exit 0"
if ((offset of "No syntax errors detected" in lintOutput) ≠ 1) then
display dialog lintOutput buttons {"OK"} default button "OK" with title "PHP Syntax Error"
end if
end if
end documentDidSave
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment