Feature #89139

Epic #83968: PSR-11 Initiative

Symfony Console Commands should be able to use dependency injection

Added by Benjamin Franzke 9 months ago. Updated 3 months ago.

Status:
Closed
Priority:
Should have
Category:
CLI
Start date:
2019-09-11
Due date:
% Done:

100%

PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

The CommandRegistry instantiates all Commands with a constructor argument (command name).
That means GeneralUtility::makeInstance can not offload to the dependency injection container.

Furthermore all commands are instantiates (always), independent from the command that is actually executed.

It should be made possible to use dependency injection for commands.
Bonus would be registration of console commands via DI tags.


Related issues

Related to TYPO3 Core - Bug #90450: Defining an alias for a command overwrites its original command name Closed 2020-02-20
Related to TYPO3 Core - Task #91534: Remove deprecated Commands.php loading Resolved 2020-05-29

Associated revisions

Revision 0360ef3b (diff)
Added by Benjamin Franzke 4 months ago

[FEATURE] Add dependency injection support for console commands

Transform CommandRegistry into a symfony CommandLoader which
allows console commands to be created on demand.
That means commands are lazy loaded in order to avoid creating
all commands with all their dependencies in every console
invocation. Command will now be loaded when they are either
executed or when command metadata is required (e.g. for
the command listing)

The `site:list` command is adapted to make use of dependency injection.

Releases: master
Resolves: #89139
Change-Id: I64256bf2dc21f0f3fe434aa5dff6176f0fe22233
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61630
Tested-by: TYPO3com <>
Tested-by: Achim Fritz <>
Tested-by: Benni Mack <>
Reviewed-by: Achim Fritz <>
Reviewed-by: Benni Mack <>

Revision c6344822 (diff)
Added by Michael Schams 4 months ago

[BUGFIX] Fix typos in change log

This patch fixes a typo in the change log for issue #89139.

Resolves: #90464
Releases: master
Change-Id: Id3cd0b968ea69be6051509f3838481b0d3f01e92
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63344
Tested-by: TYPO3com <>
Tested-by: Björn Jacob <>
Tested-by: Oliver Bartsch <>
Tested-by: Christian Eßl <>
Tested-by: Oliver Klee <>
Tested-by: Andreas Fernandez <>
Reviewed-by: Björn Jacob <>
Reviewed-by: Oliver Bartsch <>
Reviewed-by: Christian Eßl <>
Reviewed-by: Oliver Klee <>
Reviewed-by: Andreas Fernandez <>

Revision 632d92bb (diff)
Added by Chris Müller about 2 months ago

[DOCS] Fix broken examples for console command DI

In the dependency injection examples for defining a console
command a colon is missing after the class name.

Resolves: #91068
Related: #89139
Releases: master
Change-Id: Ieea67cfb3f906037a4fad7da49d3d91613a12855
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/64202
Tested-by: TYPO3com <>
Tested-by: Jonas Eberle <>
Tested-by: Björn Jacob <>
Tested-by: Oliver Bartsch <>
Tested-by: Josef Glatz <>
Tested-by: Georg Ringer <>
Reviewed-by: Oliver Klee <>
Reviewed-by: Jonas Eberle <>
Reviewed-by: Björn Jacob <>
Reviewed-by: Oliver Bartsch <>
Reviewed-by: Josef Glatz <>
Reviewed-by: Georg Ringer <>

Revision 98cf5d69 (diff)
Added by Benjamin Franzke 6 days ago

[!!!][TASK] Remove support for deprecated CLI command configuration

Configuration via Commands.php had been superseded by tag based
DI service configuration which allowed to configure DI and dependencies
for CLI commands in one place.

The CommandRegistry is refactored as the runtime merging logic
can now be dropped and handled in addLazyCommand – which is called
by the symfony DI generated factory – instead.

Resolves: #91534
Related: #91473
Related: #89139
Releases: master
Change-Id: I24fc554902650c66b8dc397708d80968514c6744
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/64603
Tested-by: Benni Mack <>
Tested-by: TYPO3com <>
Tested-by: Andreas Fernandez <>
Reviewed-by: Benni Mack <>
Reviewed-by: Andreas Fernandez <>

History

#1 Updated by Gerrit Code Review 9 months ago

  • Status changed from New to Under Review

Patch set 12 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61630

#2 Updated by Gerrit Code Review 9 months ago

Patch set 13 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61630

#3 Updated by Gerrit Code Review 6 months ago

Patch set 14 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61630

#4 Updated by Gerrit Code Review 6 months ago

Patch set 15 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61630

#5 Updated by Gerrit Code Review 6 months ago

Patch set 16 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61630

#6 Updated by Gerrit Code Review 4 months ago

Patch set 17 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61630

#7 Updated by Gerrit Code Review 4 months ago

Patch set 18 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61630

#8 Updated by Gerrit Code Review 4 months ago

Patch set 19 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61630

#9 Updated by Gerrit Code Review 4 months ago

Patch set 20 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61630

#10 Updated by Benjamin Franzke 4 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#11 Updated by Helmut Hummel 4 months ago

  • Related to Bug #90450: Defining an alias for a command overwrites its original command name added

#12 Updated by Benni Mack 3 months ago

  • Status changed from Resolved to Closed

#13 Updated by Benjamin Franzke 8 days ago

  • Related to Task #91534: Remove deprecated Commands.php loading added

Also available in: Atom PDF