celbcw
Last Updated: February 25, 2016
·
1.17K
· jamart
Be3a7e0e4d28f5da75c0a54a6ddfb3b6

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.

Say Thanks
Respond

2 Responses
Add your response

1520
985347f8d4d896aa17a3984d40971038

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

over 1 year ago ·
1523
Be3a7e0e4d28f5da75c0a54a6ddfb3b6

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 ·
Filed Under