Wednesday, 4 May 2011

PHP syntax check multiple files

Okay, so you've been modifying loads of php files, come to test the app and you get a blank screen.

Its probably a syntax error.

Easy to solve if its just one file, try using
http://www.hcibook.com/meandeviation/php-syntax-check/v5-2/syntax-check.php

But what if, as in my case, its a MVC model such as Yii. There are lots of files to check...

If you are using LAMP (Linux and Apache) then run the following from a terminal in the source directory

find . -name \*.php -exec php -l "{}" \;

This will recursively check all php files in the directory and subdirectories for syntax errors.

Full credit to http://www.electrictoolbox.com/php-command-line-syntax-checking/

No comments:

Post a Comment