Skip to content
Advertisement

PHP codesniffer path to whole project

I`m new to this but i have installed composer and with it installed PHP Codesniffer. Now, how can i use php codesnifer to check for files in my entire project folder? My directory structure is something like this:

ProjectName
    functions
        functions.php
    templates
        template.php
    myFunctions.php
    vendor
        bin
            phpcs.exe

If i try to run

phpcs --standard=PSR2 functions 

it will check the files inside of the functions files inside of the functions directory but i need it to check all the php files in the ProjectName directory.

Thank you!

Advertisement

Answer

there should be an option called “extensions” to fit your use

phpcs --extensions=php --standard=PSR2 .

where you should run this code in your project root directory since “.” points to the current directory

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement