David Patterson
David Patterson

Reputation: 1920

Why is Symfony 3.3.13 source generating a deprecation warning (not in my code)?

I am getting a deprecation notice in my Symfony 3.3.13 full-stack application.

Autowiring-types are deprecated since Symfony 3.3 and will be removed in 4.0. Use aliases instead for "Psr\Log\LoggerInterface".

Note that this is coming from Symfony source, not my code.

Clicking "Show Trace" shows that it is in file vendor/symfony/monolog-bundle/DependencyInjection/MonologExtension.php.

The code is:

if (method_exists('Symfony\Component\DependencyInjection\Definition', 'addAutowiringType')) {
         $container->getDefinition('monolog.logger')->addAutowiringType('Psr\Log\LoggerInterface');
    }

I suspect that I need to update the monolog-bundle version in my composer.json file, but haven't been able to figure out the correct version. It is currently set to "~2.8".

Upvotes: 2

Views: 1810

Answers (2)

Jannes Botis
Jannes Botis

Reputation: 11242

This is a notice that symfony autowiring has changed. Symfony Autowiring

This is just a warning, your symfony/monolog-bundle anyway checks to see if autowiring-types exists:

if (method_exists('Symfony\Component\DependencyInjection\Definition', 'addAutowiringType')) {

Your version of Symfony just kept addAutowiringType function of Symfony\Component\DependencyInjection\Definition to give you this warning.

The latest release of Monolog bundle adds the necessary alias github link

You can use version 3.1 of monolog-bundle.

If for any reason you have to use any of the previous versions, you will need to add the alias yourself in your services config.

services:
   Psr\Log\LoggerInterface: "@logger"

Upvotes: 6

David Patterson
David Patterson

Reputation: 1920

Okay. I finally thought to check Packagist for more recent monolog-bundle versions.

I changed the version in my composer.json file from "~2.8" to "~3.1" and did a composer update symfony/monolog-bundle.

Problem solved.

Upvotes: 4

Related Questions