There are multiple ways to configure PHPQA and the component tools.
The general strategy is that there is an extensive and relatively sensible default configuration. In your project you should hopefully only need to make minor adjustments by overriding it.
A key concept with PHPQA is that there should be a directory in your project root called qaConfig. This folder is used as much as possible to contain all of your QA and CI configuration, and is where you store your project-specific configuration and hooks.
PHPQA makes extensive use of bash environment variables for configuration.
There are three ways you can generally set these environment variables:
- Export them in your Bash session
export environmentVariable="value"
vendor/bin/qa- Set them inline when running PHPQA
environmentVariable="value" vendor/bin/qa- Export them as part of your CI script
#ci.bash
export CI=true
vendor/bin/qaHere are some general PHPQA environment variables you might want to set:
phpqaQuickTests
If you want to run only fast PHPQA tests.
CI
Will not prompt for user input.
skipUncommittedChangesCheck
Don't check for uncommitted changes when running.
phpqaMemoryLimit
Global memory limit for all QA tools. Default: 4G.
# Override via environment variable
phpqaMemoryLimit=8G vendor/bin/qa
# Or in qaConfig/qaConfig.inc.bash
export phpqaMemoryLimit=8GThe bulk of the configuration is handled with configuration files which are separated by platform.
- configDefaults/ contains subfolders specific to each platform
- generic/ for config files not specific to any platform
Each platform folder contains the configuration files for that platform. Where a file does not exist in the platform folder, the generic configuration file is used.
PHPQA's configDefaults/generic folder contains a config file for each tool run by PHPQA. At the moment this includes:
- infection.json
- phpstan.neon
- phpunit.xml
- php_cs.php
- psr4-validate-ignore-list.txt
- composerRequireChecker.json
- rector-safe.php
- rector-phpunit.php
- rector-php84.php
If no local config file exists in your project's qaConfig folder, PHPQA will detect what type of platform you're on and use the config in its own configDefaults/ folder.
As an example, when running PHPStan on a Symfony codebase, PHPQA will check for its config in the following order:
- Your project's root
qaConfig/phpstan.neon - PHPQA's root
configDefaults/symfony/phpstan.neon - PHPQA's root
configDefaults/generic/phpstan.neon
To create your own override:
- Make a directory in your project root called
qaConfig - Copy the configuration from configDefaults into your project
qaConfigfolder - Customise the copied config as you see fit
For example, for PHPStan:
cd /my/project/root
mkdir -p qaConfig
# Copy in the default config
platform="generic" # See vendor/lts/php-qa-ci/configDefaults/ for options
cp vendor/lts/php-qa-ci/configDefaults/${platform}/phpstan.neon qaConfig/
# Edit the config
vim qaConfig/phpstan.neonIf you want to make more wholesale tweaks to qa customisation, you can create a file in your qaConfig directory called qaConfig.inc.bash. This will be automatically detected and included, and can then override all kinds of default configuration that has occurred up to that point.
When you run qa, it checks for a file located in "$projectConfigPath/qaConfig.inc.bash" and will include it if found.
Using this you can override as much of the standard configuration as you see fit.
For example, the PHPQA project itself has a qaConfig folder which is used when PHPQA is run against itself.