Slim 4 php-view

On Slim v3, i’ve using php-view:

$container['view'] = function ($container) {
    $vars = [
        'router' => $container->get('router'),
        'base' => '//example.com',
    ];
    return new PhpRenderer(__DIR__ . '/views', $vars);
};

and for links:

<?= $router->pathFor('page'); ?>

Now with slim v4, how make this work using PHP-DI or league/container?

Hello, I was able to get this work:

$container->set('router', $app->getRouteCollector()->getRouteParser());

$container->set('view', function ($c) {
  $templatePath = __DIR__ . '/../templates/default';
  return new Slim\Views\PhpRenderer($templatePath, [
    // common data available in templates
    "router" => $c->get('router')
  ]);
});