[support] Within a drupal custom module what is a more efficient way for me to detect and fix any php syntax errors?

Greg Knaddison Greg at GrowingVentureSolutions.com
Thu Apr 15 16:06:58 UTC 2010


On Thu, Apr 15, 2010 at 9:13 AM, CM Lubinski <cmc333333 at gmail.com> wrote:
> If you are worried about syntactic errors (rather than logical ones),
> you can also run your code through php's lint.
>
> $ php -l mymodule.php
>
> Unfortunately, this only handles one file at a time, but it will tell
> you if the code can be included at all.
>

Command line fun to the rescue:

$ find ./ -type f -exec php -l {} \;

That command:
1. Finds items in the current directory and subdirectories
2. That are "type f" (i.e. files)
3. And executes a new php -l function on each file it finds

I keep that in a script called "phpchecker" in my ~/bin/ directory and
frequently use it prior to making a commit or a tag on code.

Cheers,
Greg

-- 
Greg Knaddison | 303-800-5623 | http://growingventuresolutions.com
Mastering Drupal | http://www.masteringdrupal.com


More information about the support mailing list