Maggie Nelson

Archive for May, 2007

3. Find x.

by maggie on May.21, 2007, under entry

Somehow math and smartasses tend to gravitate toward each other.


More: haha.nu.

Leave a Comment more...

How to quickly lint PHP files in an upcoming svn commit

by maggie on May.15, 2007, under entry

Nothing more embarassing than committing awesome code with a parse error. Quick

php -l

will take care of that. But if your repository has files under many directories and you’ve made changes to many files, it can be a pain to php -l all of them as you can only pass one file to “php -l” at a time.
Here’s a quick shortcut:

svn stat | grep ‘php’ | awk ‘{print “php -l ” $2}’ | sh

“svn stat” will list all files that have been changed. The grep will filter the result and only show PHP files. The awk command takes the 2nd column of the output and does “php -l” on every file in that column.
Granted, this is convenient but painful to type and error prone. Solution: save it in a file svnlint.sh, then add an alias:

alias svnlint=’sh ~/svnlint.sh’

At this point, before every:

svn commit

do:

svnlint

Your PHP files will be free of syntax errors (so you can focus on those “real” bugs…)

5 Comments more...


Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Tags

RSS Planet PHP