Recursive PHP File Syntax Check via bash (find)

Category: Software and Systems Engineering
Author: Sean O'Donnell
Wed, Sep. 12th, 2012 @ 13:28:56 (MDT)

If you want to quickly check your PHP code tree for Syntax Errors (using bash), you can run the following command(s):

find ~/workspace/myproject -iname "*.php" -exec php -l {} \; | grep -i "Errors.parsing"

The command above will perform a syntax check on all .php files (recursively) within the ‘~/workspace/myproject’ directory. This can be handy for code auditing, as well as debugging unfamiliar (and even familiar) code.

Copyleft (<) 1998-2019 www.seanodonnell.com