Using Extbase outside a frontend request 

Extbase expects a fully prepared frontend request. By the time an Extbase plugin runs, the frontend has resolved the page and built the TypoScript configuration that Extbase reads its settings from.

Outside that context, that preparation has not happened, and Extbase reacts in two different ways depending on which part of it is used. Controllers, views and anything else resolving plugin.tx_<extension> configuration fail outright. The persistence layer is deliberately allowed to run without a request, but with no configuration to draw on it limits it queries to storagePid 0 alone, so repositories might return nothing rather than report a problem.

Three contexts run into this, each with a different amount of the frontend available:

Extbase in backend modules

A request, but not a frontend one. The backend provides its own configuration, and Extbase runs in a supported but different mode.

Extbase on the command line

No request at all. Nothing of the frontend exists unless the command establishes it.

Extbase in middlewares

Anything or nothing, depending on where in the middleware chain the middleware runs — the frontend may not have been prepared yet.

Each page describes what is available in that context, what has to be established before Extbase can be used, and when the work belongs somewhere else entirely.