10000 [HttpKernel] Deprecated commands auto-registration by GuilhemN · Pull Request #23805 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpKernel] Deprecated commands auto-registration #23805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions UPGRADE-3.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,35 @@ FrameworkBundle
class has been deprecated and will be removed in 4.0. Use the
`Symfony\Component\Translation\DependencyInjection\TranslatorPass` class instead.

HttpKernel
----------

* Relying on convention-based commands discovery has been deprecated and
won't be supported in 4.0. Use PSR-4 based service discovery instead.

Before:

```yml
# app/config/services.yml
services:
# ...

# implicit registration of all commands in the `Command` folder
```

After:

```yml
# app/config/services.yml
services:
# ...

# explicit commands registration
AppBundle\Command:
resource: '../../src/AppBundle/Command/*'
tags: ['console.command']
Copy link
Contributor
@ogizanagi ogizanagi Aug 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required when using auto configuration. Given the default config that'll be promoted, should we really add this before/after at all? Or at least mention it's not required when using the new default config?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for people upgrading from the standard edition < 3.3, the others won't get a deprecation so I don't think they will even notice the change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point 👍

```

Process
-------

Expand Down
26 changes: 26 additions & 0 deletions UPGRADE-4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,32 @@ HttpFoundation
HttpKernel
----------

* Relying on convention-based commands discovery is not supported anymore.
Use PSR-4 based service discovery instead.

Before:

```yml
# app/config/services.yml
services:
# ...

# implicit registration of all commands in the `Command` folder
```

After:

```yml
# app/config/services.yml
services:
# ...

# explicit commands registration
AppBundle\Command:
resource: '../../src/AppBundle/Command/*'
tags: ['console.command']
```

* Removed the `kernel.root_dir` parameter. Use the `kernel.project_dir` parameter
instead.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# to be removed once https://github.com/doctrine/DoctrineBundle/pull/684 is merged
services:
Doctrine\Bundle\DoctrineBundle\Command\:
resource: "@DoctrineBundle/Command/*"
tags: [console.command]
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Bundle\SecurityBundle\Tests\Functional\app;

use Doctrine\ORM\Version;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpKernel\Kernel;
Expand Down Expand Up @@ -82,6 +83,11 @@ public function getLogDir()
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load($this->rootConfig);

// to be removed once https://github.com/doctrine/DoctrineBundle/pull/684 is merged
if ('Acl' === $this->testCase && class_exists(Version::class)) {
$loader->load(__DIR__.'/Acl/doctrine.yml');
}
}

public function serialize()
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/HttpKernel/Bundle/Bundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ public function registerCommands(Application $application)
}
$r = new \ReflectionClass($class);
if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract() && !$r->getConstructor()->getNumberOfRequiredParameters()) {
@trigger_error(sprintf('Auto-registration of the command "%s" is deprecated since Symfony 3.4 and won\'t be supported in 4.0. Use PSR-4 based service discovery instead.', $class), E_USER_DEPRECATED);

$application->add($r->newInstance());
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/HttpKernel/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CHANGELOG
3.4.0
-----

* deprecated commands auto registration
* added `AddCacheClearerPass`
* added `AddCacheWarmerPass`

Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public function testGetContainerExtension()
);
}

/**
* @group legacy
* @expectedDeprecation Auto-registration of the command "Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command\FooCommand" is deprecated since Symfony 3.4 and won't be supported in 4.0. Use PSR-4 based service discovery instead.
*/
public function testRegisterCommands()
{
$cmd = new FooCommand();
Expand Down
0