Recursive PHP Lint-inator

Josh Sherman
1 min read
Command-line Interface Shell Script PHP

Just cleaning up a repository at work and came across a script I haven’t used in forever, a script to lint all PHP files in a directory, recursively.

Expect something more stimulating soon as I found out the hard way that tumblr doesn’t seem to auto-save your posts once you’ve saved them once as a draft. Or I’m an idiot, either way, enjoy the script.


for file in `find .`

    if [ "$EXTENSION" == "php" ] || [ "$EXTENSION" == "phtml" ]
        RESULTS=`php -l $file`

        if [ "$RESULTS" != "No syntax errors detected in $file" ]
            echo $RESULTS

And yes, the title is a Dr. Doofenshmirtz reference.

Join the Conversation

Good stuff? Want more?

Weekly emails about technology, development, and sometimes sauerkraut.

100% Fresh, Grade A Content, Never Spam.

About Josh

Husband. Father. Pug dad. Born again Linux user. Founder of Holiday API, and author of the best damn Lorem Ipsum Library for PHP.

Currently Reading

Slobberknocker: My Life in Wrestling
The 4-Hour Workweek, Expanded and Updated

Previous Reads

Buy Me a Coffee Become a Sponsor

Related Articles