Configuring deprecation warnings when running tests in Symfony

Some background

If you're using Symfony for a while, you're probably aware of the SYMFONY_DEPRECATIONS_HELPER environment variable that you can set in phpunit.xml config. The variable is part of the and comes with most default Symfony PHP Framework installs.

I personally found the naming of the options not very intuitive, and until I played around to figure out the behavior, I didn't really get how they were supposed to be working.

The options

  • max[total]
  • max[self]
  • max[direct]
  • max[indirect]
  • verbose
  • ignoreFile
  • logFile
  • quiet


The max option is used to set a threshold on the number of deprecation notices, either based on their type (direct, indirect) or total number, after which the command line returns an error exit code.

There are several types of suboptions for max:

  • max[total] - sets a threshold on the total number of deprecations, both direct and indirect
  • max[direct] - puts a threshold on deprecations that resulted directly from your code
  • max[indirect] - sets a threshold for on the number of deprecations caused by dependencies
  • max[self] - used for libraries that use the depreaction system themselves and cannot afford to use any of the other configurations from above
SYMFONY_DEPRECATIONS_HELPER="max[total]=100" ./vendor/bin/phpunit


The verbose option is used to get more details about the exact files in which the depreaction notices were triggered. It's often used in a url encoded manner with other options:

SYMFONY_DEPRECATIONS_HELPER="max[total]=100&verbose=1" ./vendor/bin/phpunit


The ignoreFile option can be used to define inside a file a list of deprecation notices that should be ignored. Note that this feature was introduced starting with Symfony 6.1

SYMFONY_DEPRECATIONS_HELPER="ignoreFile=./tests/ignoreFile.txt" ./vendor/bin/phpunit

ignoreFile.txt :


Basically each row represents a pattern of the files that should be ignored.

generateBaseline & baselineFile

In order to create a baseline file you can use the generateBaseline and baselineFile options as follows:

SYMFONY_DEPRECATIONS_HELPER='generateBaseline=true&baselineFile=./tests/baseline-file.json' ./vendor/bin/phpunit

After the baseline file is generated you could run the tests without the generation option like:

SYMFONY_DEPRECATIONS_HELPER='baselineFile=./tests/baseline-file.json' ./vendor/bin/phpunit


If you prefer turning off verbose output and write all of the deprecation notices in a file you can use the logFile option. Note that this option also hides the count of deprecation notices at the end of the test run.

SYMFONY_DEPRECATIONS_HELPER='logFile=./var/log/deprecations.log' ./vendor/bin/phpunit


The quiet option allows to change the verbosity more granularly than vebose and does so per type of deprecation. For example if you want to hide all indirect deprecation notices you could use something like:

SYMFONY_DEPRECATIONS_HELPER='quiet[]=indirect' ./vendor/bin/phpunit

One important thing to note about quiet is that, similarly to vebose, it just hides the details of the deprecations but doesn't change the exist code of the command in any way if the number of threshold deprecations was reached.

Unlike logFile, when using quiet, the count of deprecation notices is still shown.