KnpLabs/KnpGaufretteBundle

FilesystemKeysCommand - Command auto-registration is deprecated since Symfony 3.4

valkars opened this issue ยท 9 comments

Spotted while running tests in an app upgraded to Symfony 3.4:
Auto-registration of the command "Knp\Bundle\GaufretteBundle\Command\FilesystemKeysCommand" is deprecated since Symfony 3.4 and won't be supported in 4.0. Use PSR-4 based service discovery instead

https://symfony.com/doc/3.4/console/commands_as_services.html
I guess that the easiest solution is to register this command as service.

Hello @valkars :)

Thank you for reporting this issue. Can you provide a code snippet or an explanation about how you have encountered this warning please so we can reproduce it ?

CommandTest.txt

It is a command test for phpunit, after it's execution there are deprecation notices:

Remaining deprecation notices (1)
  1x: Auto-registration of the command "Knp\Bundle\GaufretteBundle\Command\FilesystemKeysCommand" is deprecated since Symfony 3.4 and won't be supported in 4.0. Use PSR-4 based service discovery instead.
    1x in CommandTest::testExecute from Tests\Command

In my case there are tests for our commands, but it looks like Symfony looks up for all existing commands and prints this message about Gaufrette command.
You need symfony 3.4 + KnpGaugfretteBundle installed, I hope this helps

Symfony also looks in the Command/ directory of each bundle for commands non registered as a service and automatically registers those classes as commands. However this auto-registration was deprecated in Symfony 3.4. In Symfony 4.0, commands won't be auto-registered anymore.

So I guess that the easiest way is:

You can also manually register your command as a service by configuring the service and tagging it with console.command.

services:
    AppBundle\Command\SunshineCommand:
        tags:
            - { name: 'console.command', command: 'app:sunshine' }

OK thank you for the snippet, I was able to reproduce. #183 fixes it.

Fix released in v0.5.2, thank you @valkars for pointing this out ๐Ÿ‘

Thanks for the release, but unfortunately in https://packagist.org/packages/knplabs/knp-gaufrette-bundle - there is only 0.5.0 is available and composer doesn't update this bundle to 0.5.2. Do you know why? ๐Ÿ˜•

I think this was due to #184 . This should be OK now (the v0.5.2 release is visible on packagist).

Thanks ๐Ÿ‘