VOOZH about

URL: https://hub.docker.com/r/eko3alpha/docker-phpqa/

⇱ eko3alpha/docker-phpqa - Docker Image


eko3alpha/docker-phpqa

By eko3alpha

Updated over 6 years ago

Docker PHP QA

Image
5

10K+

eko3alpha/docker-phpqa repository overview

docker-phpqa

Docker image for running PHP QA Tools

Example

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

Alias

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

Analyze

CommandDescription
phpqa --helpShow help - available options, tools, default values, ...
phpqa --analyzedDirs ./ --buildDir ./buildAnalyze current directory and save output to build directory
phpqa --analyzedDirs src,testsAnalyze source and test directory (phpmetrics analyzes only src)
Deprecated in v1.8 in favor of --analyzedDirs
phpqa --ignoredDirs build,vendorIgnore directories
phpqa --ignoredFiles RoboFile.phpIgnore files
phpqa --tools phploc,phpcsRun only selected tools
phpqa --tools phpmd:1,phpcs:0,phpcpd:0Check number of errors and exit code. New in v1.6
phpqa --verboseShow output from executed tools
phpqa --quietShow no output at all
phpqa --output cliCLI output instead of creating files in --buildDir
phpqa --execution no-parallelDon't use parallelism if --execution != parallel
phpqa --config ./my-configUse custom configuration
phpqa --reportBuild html reports
phpqa toolsShow versions of available tools

Output modes

Additional tools

The following tools are preinstalled. phpstan is experimental and will need to be manually specified in --tools.

ToolPHPSupported sinceDescriptionStatus
php-cs-fixer>= 5.31.12Automatically detect and fix PHP coding standards issuesstable
parallel-lint>= 5.41.9Check syntax of PHP filesstable
phpstan>= 7.01.9Discover bugs in your code without running itexperimental (v0.7)

PHP Mess Detector

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

Tag summary

latest

Content type

Image

Digest

Size

90.1 MB

Last updated

over 6 years ago

docker pull eko3alpha/docker-phpqa