4

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!

Cata John
  • 1,371
  • 11
  • 19
  • Have you tried `phpcs --standard=PSR2 /path/to/ProjectName` or even changing into the ProjectName folder and running `phpcs --standard=PSR2 .`? If you want to exclude the `vendor` dir, make sure you also use `--ignore=*/vendor/*`. Is this what you are asking? – Greg Sherwood Apr 11 '17 at 23:20

2 Answers2

4

You can use dot sign "." to check current directory.

phpcs --standard=PSR2 .
Community
  • 1
  • 1
Tomas Votruba
  • 23,240
  • 9
  • 79
  • 115
4

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

gz-ang
  • 56
  • 1