-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commands auto-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 commands registration | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be updated as in the upgrade 4.0 file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
``` | ||
|
||
After: | ||
|
||
```yml | ||
# app/config/services.yml | ||
services: | ||
# ... | ||
|
||
# explicit commands registration | ||
AppBundle\Command: | ||
resource: '../../src/AppBundle/Command/*' | ||
tags: ['console.command'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair point 👍 |
||
``` | ||
|
||
Process | ||
------- | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -452,6 +452,32 @@ HttpFoundation | |
HttpKernel | ||
---------- | ||
|
||
* Relying on commands auto-discovery has been deprecated and won't be supported | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is not supported anymore There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indeed |
||
in 4.0. Use PSR-4 based Service Discovery instead. | ||
|
||
Before: | ||
|
||
```yml | ||
# app/config/services.yml | ||
services: | ||
# ... | ||
|
||
# implicit commands registration | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe add "implicit registration of all commands in the |
||
``` | ||
|
||
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. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is using PSR4 registration enough? that won't remove that notice, isn't it? people need also to override the registerCommands method in their bundle? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need as long as they register all their commands as services. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. enough indeed, registering the command as a service makes convention based skipped thanks to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think "Service Discovery" should be written with capital letters as it doesn't reference a fixed term or feature name. |
||
|
||
$application->add($r->newInstance()); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we put
convention-based
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it better like that? :)