validatePHP.py

« Back to python scripts | Back to projects

I use SVN for most of my projects so I have working copies of PHP applications. In efforts to work more agilely, I wanted to create a script to pass my PHP code through the syntax checker. This is the first part of the that process.

Description

Runs all the PHP files in a given directory through the PHP syntax checker.

Sample usage

>>> import validatePHP
>>> for error in validate_path('/Users/me/svn/project1/'):
...   print "Error in %s:" % error["file"]
...   print "\t%s" % error["error"]
Error in /Users/me/svn/project1/sample.php:
    Parse error: ...

Or from the command line:

$ python validatePHP.py -sc /Users/me/svn/project1/
1. Parse error: ...
/Users/me/svn/project1/:  1 error

Download

This script is available under a BSD license.

FileVersionSizeMD5
validatePHP.py.zip0.14 KBae413e6a31df7b352b5aa7e517b2b846

Known Issues

PHP files must be saved with a .php extension currently. If your files are saved with another name, you will have to modify the script.

Submitting issues

You can submit issues by using my contact form.