How to integrate Twig


I’m trying to integrate Twig, but following the official docs, I cant get it to work.

Using \Slim\App(); as the docs (in twig section) say, doesn’t work, as App doesn’t exist.

---- EDIT ----

I was using the docs of v2…

As I’m sure you’ve worked out, you need Twig-View for Slim 3.

If it says App doesn’t exits it means Slim classes are not available(loaded) in your code. Maybe you forgot to require it with composer autoloader like this:

require __DIR__ . '/vendor/autoload.php';

The other thing you are saying is to try to integrate Twig. Twig already has been integrated in Slim 3. All you have to do is to use the Twig-View as @akrabat suggested.