![]() |
VOOZH | about |
Docker image for running PHP QA Tools
docker run --rm -u $UID -v $PWD:/app eko3alpha/docker-phpqa --report --ignoredDirs vendor,build,migrations,test
Here is a breakdown of the docker command
--rm : Cleans up any unused docker images used to create the image
-u $UID : Passes docker your existing user id so the new files will have your ownership
-v $PWD : Passes docker the existing working directory for analyzing
--report : Tells PHPQA to output HTML reports
--ignoredDirs : Directories to ignore, you can add your own
You can also create an alias so you dont have to type that whole command! More information can be found here: Dockerize Commands
OSX:
sudo pico ~/.bash_profile
Ubuntu:
sudo pico ~/.bash_aliases
Then add the following entry, in this case we're calling it "phpqa" you can change it to whatever you want. Make sure to wrap it in single quotes.
alias phpqa='docker run --rm -u "$UID" -v "$PWD:/app" eko3alpha/docker-phpqa'
After you add the entry refresh the profile
source ~/.bash_profile
Now you can use phpqa tools anywhere! Make sure you are in the root directory of your project and then run
phpqa --report
For full documentation please head over to PHP QA Docs
| Command | Description |
|---|---|
phpqa --help | Show help - available options, tools, default values, ... |
phpqa --analyzedDirs ./ --buildDir ./build | Analyze current directory and save output to build directory |
phpqa --analyzedDirs src,tests | Analyze source and test directory (phpmetrics analyzes only src) |
Deprecated in v1.8 in favor of --analyzedDirs | |
phpqa --ignoredDirs build,vendor | Ignore directories |
phpqa --ignoredFiles RoboFile.php | Ignore files |
phpqa --tools phploc,phpcs | Run only selected tools |
phpqa --tools phpmd:1,phpcs:0,phpcpd:0 | Check number of errors and exit code. New in v1.6 |
phpqa --verbose | Show output from executed tools |
phpqa --quiet | Show no output at all |
phpqa --output cli | CLI output instead of creating files in --buildDir |
phpqa --execution no-parallel | Don't use parallelism if --execution != parallel |
phpqa --config ./my-config | Use custom configuration |
phpqa --report | Build html reports |
phpqa tools | Show versions of available tools |
| Tool | --output file (default) - generated files | --output cli |
|---|---|---|
| phploc | phploc.xml | ✓ |
| phpcpd | phpcpd.xml | ✓ |
| phpcs | checkstyle.xml | full report |
| pdepend | pdepend-jdepend.xml, pdepend-summary.xml, pdepend-dependencies.xml, pdepend-jdepend.svg, pdepend-pyramid.svg | ✗ |
| phpmd | phpmd.xml | ✓ |
| phpmetrics | phpmetrics.html (v1), phpmetrics/index.html (v2), phpmetrics.xml | ✓ |
| php-cs-fixer | php-cs-fixer.html | ✓ |
| parallel-lint | parallel-lint.html | ✓ |
| phpstan | phpstan.html, phpstan-phpqa.neon | ✓, phpstan-phpqa.neon |
The following tools are preinstalled. phpstan is experimental and will need to be manually specified in --tools.
| Tool | PHP | Supported since | Description | Status |
|---|---|---|---|---|
| php-cs-fixer | >= 5.3 | 1.12 | Automatically detect and fix PHP coding standards issues | stable |
| parallel-lint | >= 5.4 | 1.9 | Check syntax of PHP files | stable |
| phpstan | >= 7.0 | 1.9 | Discover bugs in your code without running it | experimental (v0.7) |
If you want to change the rules for PHPMD first go here and generate your own rules. Below is a sample output
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="pcsg-generated-ruleset"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>Created with the PHP Coding Standard Generator. http://edorian.github.com/php-coding-standard-generator/
</description>
<rule ref="rulesets/controversial.xml/Superglobals"/>
<rule ref="rulesets/design.xml/ExitExpression"/>
<rule ref="rulesets/design.xml/EvalExpression"/>
<rule ref="rulesets/design.xml/GotoStatement"/>
<rule ref="rulesets/naming.xml"/>
<rule ref="rulesets/unusedcode.xml"/>
</ruleset>
Once you create your own rule set, copy and paste the XML into a file. In this example we're naming the file
phpmd.rules.xml
PHPQA will search for a YML file named .phpqa.yml in the directory you to run this docker file from. In this YML file there is a section for phpmd
phpmd:
standard: phpmd.rules.xml
Make sure the location of the xml file (phpmd.rules.xml) is relative to .phpqa.yml. Save and run the docker file.
docker run --rm -u $UID -v $PWD:/app eko3alpha/docker-phpqa --report --tools phpmd --verbose
or if you created an alias
phpqa --report --tools phpmd --verbose
Content type
Image
Digest
Size
90.1 MB
Last updated
over 6 years ago
docker pull eko3alpha/docker-phpqa