This project is a collection of PHP_CodeSniffer rules (sniffs) to validate code developed for FunPlus.
Standards can be installed with Composer dependency manager:
composer create-project fp-coding-standards/fpcs:dev-master --no-dev
Running this command will:
- Install FunPlus standards into
fpcsdirectory. - Install PHP_CodeSniffer.
- Register FunPlus standards in PHP_CodeSniffer configuration.
- Make
phpcscommand available fromfpcs/vendor/bin.
For convenience of using phpcs as global command you might want to add path to fpcs/vendor/bin directory to a PATH environment of your operating system.
- Install PHP_CodeSniffer by following its installation instructions (via Composer, PEAR, or Git checkout).
Do ensure, if for example you're using VVV, that PHP_CodeSniffer's version matches our requirements (you can check the required version in composer.json).
-
Clone FunPlus standards repository:
git clone -b master https://github.com/funplus/FunPlus-Coding-Standards.git fpcs -
Add its path to PHP_CodeSniffer configuration:
phpcs --config-set installed_paths /path/to/fpcs
To summarize:
cd ~/projects
git clone https://github.com/squizlabs/PHP_CodeSniffer.git phpcs
git clone -b master https://github.com/funplus/FunPlus-Coding-Standards.git fpcs
cd phpcs
./scripts/phpcs --config-set installed_paths ../fpcsAnd then add the ~/projects/phpcs/scripts directory to your PATH environment variable via your .bashrc.
You should then see FunPlus et al listed when you run phpcs -i.
Run the phpcs command line tool on a given file or directory, for example:
phpcs --standard=FunPlus somephpfile.php
The project encompasses a super–set of the sniffs that the FunPlus community may need. If you use the FunPlus standard you will get all the checks.
You can use the following as standard names when invoking phpcs to select sniffs, fitting your needs:
FunPlus— all of the sniffs in the project.
If you need to further customize selection of sniffs for your project — you can create custom ruleset.xml standard. See fully annotated example in PHP_CodeSniffer documentation.
See LICENSE (MIT).