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

Conversation

GuilhemN
Copy link
Contributor

@GuilhemN GuilhemN commented Aug 6, 2017

Q A
Branch? 3.4
Bug fix? no
New feature? no
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets #23488
License MIT
Doc PR

Deprecates commands auto-registration. See #23488 for arguments.

@GuilhemN
Copy link
Contributor Author

GuilhemN commented Aug 6, 2017

Looks like we need to update the DoctrineBundle first.

UPGRADE-3.4.md Outdated
HttpKernel
----------

* Relying on commands auto-discovery has been deprecated and won't be supported
Copy link
Member

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?

Copy link
Contributor Author

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? :)

UPGRADE-4.0.md Outdated
@@ -452,6 +452,32 @@ HttpFoundation
HttpKernel
----------

* Relying on commands auto-discovery has been deprecated and won't be supported
Copy link
Member

Choose a reason for hiding this comment

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

is not supported anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

indeed

# 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 👍

@@ -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);
Copy link
Member

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No need as long as they register all their commands as services.

Copy link
Member

@chalasr chalasr Aug 8, 2017

Choose a reason for hiding this comment

The 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 console.command.ids parameter

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

UPGRADE-4.0.md Outdated
services:
# ...

# implicit commands registration
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add "implicit registration of all commands in the Command folder" for clarity

UPGRADE-3.4.md Outdated
----------

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

Choose a reason for hiding this comment

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

Typo :) (discovery)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops indeed :)


# to be removed once https://github.com/doctrine/DoctrineBundle/pull/684 is merged
services:
Doctrine\Bundle\DoctrineBundle\Command\:
Copy link
Contributor Author

@GuilhemN GuilhemN Aug 9, 2017

Choose a reason for hiding this comment

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

This is temporary :) This way this PR is mergeable.

UPGRADE-3.4.md Outdated
services:
# ...

# implicit commands registration
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be updated as in the upgrade 4.0 file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Tobion added a commit that referenced this pull request Aug 9, 2017
…ilhemN)

This PR was squashed before being merged into the 3.4 branch (closes #23805).

Discussion
----------

[HttpKernel] Deprecated commands auto-registration

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | no <!-- don't forget updating src/**/CHANGELOG.md files -->
| BC breaks?    | no
| Deprecations? | yes <!-- don't forget updating UPGRADE-*.md files -->
| Tests pass?   | yes
| Fixed tickets | #23488
| License       | MIT
| Doc PR        |

Deprecates commands auto-registration. See #23488 for arguments.

Commits
-------

14215d8 [HttpKernel] Deprecated commands auto-registration
@Tobion
Copy link
Contributor

Tobion commented Aug 9, 2017

Thank you @GuilhemN

@GuilhemN GuilhemN deleted the implicitcommands branch August 9, 2017 17:04
xabbuh added a commit to symfony/symfony-docs that referenced this pull request Sep 3, 2017
…emN)

This PR was squashed before being merged into the 3.4 branch (closes #8269).

Discussion
----------

[Console] Commands auto-registration is deprecated

Document symfony/symfony#23805.

I wonder, should I update https://github.com/symfony/symfony-docs/blob/17d1c39298e9415886e2c712748d3021ed7865a4/bundles/best_practices.rst L122 (`Command/  Yes`) ? As it is not really mandatory to use the `Command/` directory anymore.

Commits
-------

493ae89 [Console] Commands auto-registration is deprecated
This was referenced Oct 18, 2017
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.

6 participants