Collection of commonly used php QA tools.
Included in this package are:
- phpunit/phpunit The PHP Unit Testing framework.
- phploc/phploc A tool for quickly measuring the size of a PHP project.
- phpmd/phpmd PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD.
- squizlabs/php_codesniffer PHP_CodeSniffer tokenises PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.
- fabpot/php-cs-fixer Analyzes some PHP source code and tries to fix coding standards issues (PSR-1 and PSR-2 compatible).
- sebastian/phpcpd Copy/Paste Detector (CPD) for PHP code.
- sensiolabs/security-checker PHP frontend for security.symfony.com.
- phpstan/phpstan A PHP Static Analysis Tool.
- vimeo/psalm A static analysis tool for PHP.
Global install
composer global require bear/qatools
Local install
composer require bear/qatools
cp vendor/bear/qatools/phpunit.xml.dist phpunit.xml
cp vendor/bear/qatools/phpcs.xml .
cp vendor/bear/qatools/phpmd.xml .
cp vendor/bear/qatools/.php_cs.dist .php_cs
for CI web service
cp vendor/bear/qatools/.travis.yml .
cp vendor/bear/qatools/.scrutinizer.yml .
When using file header, You need to edit the header section in.php_cs
.
$header = <<<'EOF'
This file is part of the __PACKAGE__ package.
@license http://opensource.org/licenses/MIT MIT
EOF;
Place edit the header text then uncomment header_comment
section.
// 'header_comment' => ['header' => $header, 'commentType' => 'comment', 'separate' => 'none'],
Although I tried to set config as based on what is used in the standard, Please change on demand.
phpcs
, phpmd
, phpunit
, php-cs-fixer
, pdepend
, phploc
, and php-cs-fixer
will be executed in order. This is the ideal for CI.
global
~/.composer/vendor/bin/phpbuild
local
vendor/bin/phpbuild
Since php-cs-fixer
only issues a warning, please modify the code with php-cs-fixer fix src
command if necessary.
phpunit
vendor/bin/phpunit
phpunit + phpmd + phpcs + php-cs-fixer + phpstan + psalm
vendor/bin/phptest
php-cs-fixer
vendor/bin/php-cs-fixer fix src
phpcs
vendor/bin/phpcs --standard=./phpcs.xml src
vendor/bin/phpcs --standard=./phpcs.xml --warning-severity=false src
vendor/bin/phpcs --standard=vendor/bear/qatools/phpcs.xml --warning-severity=false src
security-checker
vendor/bin/security-checker security:check
phpstan
vendor/bin/phpstan analyse -l max src
psalm
vendor/bin/psalm
phploc
vendor/bin/phploc src
phpcpd
vendor/bin/phpcpd src