0

I'm using Slim Framework 3 with PHP-DI/Slim-Bridge. This is my container:

$builder->addDefinitions([
            'settings.displayErrorDetails' => true,

            'router' => get(Router::class),

            Twig::class => function(ContainerInterface $c) {
                $twig = new Twig(__DIR__.'/../resources/views', [
                   'cache'=> false
                ]);

                $twig->addExtension(new TwigExtension(
                    $c->get('router'),
                    $c->get('request')->getUri()
                ));

                return $twig;
            }
   ]);

How can I get the twig object back out of the container? I tried $container->twig, but I'm not able to get the object back.

Brent
  • 21
  • 1
  • 6

1 Answers1

0

Try $container->get(Twig::class).

I invite you to read Getting started with PHP-DI.

Matthieu Napoli
  • 48,448
  • 45
  • 173
  • 261