mario-naether/php-ci-template

提供一些PHP质量保证工具和Codeception扩展


README

Latest Stable Version Latest Unstable Version License Build Status PHP runtimes PHP runtimes

此包提供一些PHP质量保证工具,灵感来源于http://jenkins-php.org/

##使用Codeception进行单元测试 ####模块

###Factory Muffin Faker

###Faker

###使用PhantomJS安装器,在composer.json中添加以下代码

"scripts-dev": {
    "post-install-cmd": [
        "PhantomInstaller\\Installer::installPhantomJS"
    ],
    "post-update-cmd": [
        "PhantomInstaller\\Installer::installPhantomJS"
    ]
}

##质量保证工具 ###使用一条命令分析PHP代码

edgedesign/phpqa

  • phploc
  • phpcpd
  • phpcs
  • pdepend
  • phpmd
  • phpmetrics
vendor/bin/phpqa --analyzedDirs ./examples/src/ --buildDir ./build/logs --report

要使用此方法在PHP QA工具中进行工作副本/粘贴检测

PHP 5.4/5.5

composer require sebastian/phpcpd:dev-master#de90566 --ignore-platform-reqs php

###使用单独的命令分析PHP代码

mkdir build/logs

####pdepend (https://pdepend.org/)

vendor/bin/pdepend --jdepend-xml=./build/logs/pdepend-jdepend.xml --summary-xml=./build/logs/pdepend-summary.xml --dependency-xml=./build/logs/pdepend-dependencies.xml --jdepend-chart=./build/logs/pdepend-jdepend.svg --overview-pyramid=./build/logs/pdepend-pyramid.svg ./examples/src/

####phpcpd (https://github.com/sebastianbergmann/phpcpd)

vendor/bin/phpcpd --log-pmd build/logs/pmd-cpd.xml ./examples/src

####phploc (https://github.com/sebastianbergmann/phploc)

vendor/bin/phploc --progress  --exclude=vendor ./examples/src/ --log-xml ./build/logs/phploc.xml

####phpmd (https://phpmd.org/)

vendor/bin/phpmd examples/src xml ./vendor/edgedesign/phpqa/app/phpmd.xml --suffixes php  --exclude /vendor/ --reportfile ./build/logs/phpmd.xml

####phpcs (https://github.com/squizlabs/PHP_CodeSniffer)

vendor/bin/phpcs -p --extensions=php --standard=PSR2  --ignore=*/vendor/* ./examples/src/ --report=checkstyle --report-file=./build/logs/checkstyle.xml

####phpmetrics (https://github.com/phpmetrics/PhpMetrics)

vendor/bin/phpmetrics ./examples/src/ --extensions php  --excluded-dirs="vendor" --offline --report-html ./build/logs/phpmetrics.html --report-xml ./build/logs/phpmetrics.xml

####php-cs-fixer (https://github.com/FriendsOfPHP/PHP-CS-Fixer)

vendor/bin/php-cs-fixer fix

####ApiGen (https://github.com/ApiGen/ApiGen)

vendor/bin/apigen generate