Skip to content

SF 4+ does not rely on Command inheritance anymore #9403

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

Merged
merged 1 commit into from
Mar 7, 2018
Merged

SF 4+ does not rely on Command inheritance anymore #9403

merged 1 commit into from
Mar 7, 2018

Conversation

bpolaszek
Copy link
Contributor

As stated in UPGRADE FROM 3.x to 4.0, relying on convention-based commands discovery is not supported anymore.

This trick will only work with bundle autoconfiguration, which is not enabled by default on many 3rd-party bundles. This means a 3rd party bundle that wants to upgrade from SF 3.4 to SF 4.0 doesn't just have to edit its composer.json, its commands must either be tagged with console.command or autoconfigured.

When struggling with this my eyes just hit the Symfony registers any PHP class extending Command as a console command automatically sentence and I didn't figure out why it didn't work.

@bpolaszek
Copy link
Contributor Author

Link is broken, please wait while I fix it...

As stated in [UPGRADE FROM 3.x to 4.0](https://github.com/symfony/symfony/blob/master/UPGRADE-4.0.md#httpkernel), relying on convention-based commands discovery is not supported anymore.

This trick will only work with bundle autoconfiguration, which is not enabled by default on many 3rd-party bundles. This means a 3rd party bundle that wants to upgrade from SF 3.4 to SF 4.0 doesn't just have to edit its `composer.json`,  its commands must either be tagged with `console.command` or autoconfigured.

When [struggling with this](https://stackoverflow.com/questions/49134340/symfony-4-3rd-party-bundle-commands-are-no-longer-automatically-discovered) my eyes just hit the _Symfony registers any PHP class extending Command as a console command automatically_ sentence and I didn't figure out why it didn't work.
@javiereguiluz
Copy link
Member

@bpolaszek this is a really important fix because wrong docs are worse than no docs. Thanks for contributing this and congrats on your first Symfony Docs contribution!

@javiereguiluz javiereguiluz merged commit f8fef4a into symfony:4.0 Mar 7, 2018
javiereguiluz added a commit that referenced this pull request Mar 7, 2018
…szek)

This PR was merged into the 4.0 branch.

Discussion
----------

SF 4+ does not rely on Command inheritance anymore

As stated in [UPGRADE FROM 3.x to 4.0](https://github.com/symfony/symfony/blob/master/UPGRADE-4.0.md#httpkernel), relying on convention-based commands discovery is not supported anymore.

This trick will only work with bundle autoconfiguration, which is not enabled by default on many 3rd-party bundles. This means a 3rd party bundle that wants to upgrade from SF 3.4 to SF 4.0 doesn't just have to edit its `composer.json`,  its commands must either be tagged with `console.command` or autoconfigured.

When [struggling with this](https://stackoverflow.com/questions/49134340/symfony-4-3rd-party-bundle-commands-are-no-longer-automatically-discovered) my eyes just hit the _Symfony registers any PHP class extending Command as a console command automatically_ sentence and I didn't figure out why it didn't work.

Commits
-------

f8fef4a SF 4+ does not rely on Command inheritance anymore
@bpolaszek
Copy link
Contributor Author

Thank you @javiereguiluz 👍

javiereguiluz added a commit that referenced this pull request Mar 9, 2018
…guiluz)

This PR was squashed before being merged into the 2.7 branch (closes #9408).

Discussion
----------

Added a short section about registering commands

After merging #9403, I realized that we could add a short section explaining that commands must be registered (although Symfony does this for you most of the times). If we merge this, in 3.4 I'll change the description to mention the autoconfiguration instead of this, which is what #9403 fixed.

Commits
-------

2efefea Added a short section about registering commands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants