# Slim 4 php-view

**URL:** <https://discourse.slimframework.com/t/slim-4-php-view/3343>\
**Category:** Questions\
**Created:** [August 12, 2019, 11:47pm UTC](https://discourse.slimframework.com/t/slim-4-php-view/3343 "2019-08-12T23:47:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TiagoNET](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/tiagonet/32/927_2.png) [@TiagoNET](https://discourse.slimframework.com/u/TiagoNET)\
**Post date:** [August 12, 2019, 11:47pm UTC](https://discourse.slimframework.com/t/slim-4-php-view/3343/1 "2019-08-12T23:47:45Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![paooolino](https://avatars.discourse-cdn.com/v4/letter/p/c68b51/32.png) [@paooolino](https://discourse.slimframework.com/u/paooolino)\
**Post date:** [December 19, 2019, 11:09am UTC](https://discourse.slimframework.com/t/slim-4-php-view/3343/2 "2019-12-19T11:09:51Z")

</div>

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')
  ]);
});
```
