I’m still confused by the structure of Slim 4 and its decoupling of everything.
The upgrade guide says:
Changes to Container
Slim no longer has a Container so you need to supply your own. If you were relying on request or response being in the container, then you need to either set them to a container yourself, or refactor. Also,
App::__call()method has been removed, so accessing a container property via
$app->key_name()no longer works.
I need to access the request (specifically, the POST data) within the context of a class’s method.
In Slim 2, I could do:
global $app; $req = $app->request();
In Slim 3, I could do:
global $app; $request = $app->getContainer()->get('request')
What’s the Slim 4 way to access it?
FYI, I’m creating my container like so:
$container = new \DI\Container(); AppFactory::setContainer($container); $app = AppFactory::create(); $container = $app->getContainer();
Thanks for the insight.