Last Updated: February 25, 2016
·
1.41K
· jamart

An easy way to test php syntax in shell

Go to your php project directory and type this:

find * -type f -name '*.php' -exec php -l {} 1> /dev/null \;

If it return nothing all is ok.

2 Responses
Add your response

Alternative without sed: find . -type f -name '*.php' -exec php -l {} > /dev/null +

over 1 year ago ·

Thanks for your comment. I am a noob in shell but I prefer your method in the find, but i can't use the -exec option form more of one line, I need to continue using xargs. My new version of the command:
find * -type f -name '*.php' | xargs -I x php -l x 1> /dev/null

In the same way, if it not return nothing all is ok, but now if we have errors the output is better

over 1 year ago ·