Issue Bug Closed

#105554Enable Extbase to be used in console commands

Lina Wolf 11/07/24, 10:15 updated 12/02/25, 14:32

Description

There are valid reasons to use components of Extbase such as Repositories inside a CLI.

Currently you have to employ a workaround like

Bootstrap::initializeBackendAuthentication();
$configurationManager = GeneralUtility::makeInstance(ConfigurationManagerInterface::class);
$configurationManager->setRequest(
    (new ServerRequest())->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_BE)
);

And make sure that your Exbase classes are not injected but retrieved with GU:makeInstance.

Reviews 2

History 1316

  1. Eike Starkmann commented <span data-processor="relativetime" data-value="2024-12-16T10:10:34+00:00" > 12/16/24, 10:10 </span>

    This problem has two sides:
    1. Injection cant be done due to missing request
    2. TS settings are not accessible in cli due to missing request.

    This workaround does fix issue 1. but not 2.

    We came up with a small extension to address both issues:
    https://github.com/undkonsorten/extbase-cli-aware-configuration-manager

    This extension provides a configuration manager for cli context in TYPO3.
    You can define via site identifier where TYPO3 should look for TS in cli context.

    In my option the core might need a third configuration manager for cli besides frontend and backend.

  2. Felix Nagel commented <span data-processor="relativetime" data-value="2025-03-12T17:03:22+00:00" > 03/12/25, 17:03 </span>

    Is there any public extension in which the workaround is implemented and working?

  3. Felix Nagel commented <span data-processor="relativetime" data-value="2025-03-13T08:57:12+00:00" > 03/13/25, 08:57 </span>

    Garvin Hicking wrote in #note-7:
    > @fnagel Maybe https://gitlab.com/reelworx/typo3/t3-fakefrontend helps

    Thanks for the hint. Looks interesting but does not work for TYPO3 v13.

  4. Aimeos no-lastname-given commented and changed priority Should have Must have Is Regression 1 <span data-processor="relativetime" data-value="2025-03-13T10:46:15+00:00" > 03/13/25, 10:46 </span>

    We can confirm too that this is a problem in scheduler tasks requiring the router for generating URLs e.g. for e-mails. Thus, that part of the Aimeos extension doesn’t work for TYPO3 v13 at the moment.

  5. Felix Nagel commented <span data-processor="relativetime" data-value="2025-03-17T10:25:09+00:00" > 03/17/25, 10:25 </span>

    Eike Starkmann wrote in #note-10:
    > As i mention above this extension does this:
    > https://github.com/undkonsorten/extbase-cli-aware-configuration-manager

    Thanks for hint! Sadly, I was not able to get it running.
    There is an existing ticket describing the issue: https://github.com/undkonsorten/extbase-cli-aware-configuration-manager/issues/1

  6. Gerrit Code Review pushed patch set 1 for main to change 88854 status Accepted Under Review <span data-processor="relativetime" data-value="2025-03-31T22:05:58+00:00" > 03/31/25, 22:05 </span>

  7. Georg Ringer commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2025-04-01T13:00:11+00:00" > 04/01/25, 13:00 </span>

    Applied in changeset commit:7cd4e615c3ccfdbb1e1e6826992426550ab536c0.