# Slim 4 slim / twig render impossible

**URL:** <https://discourse.slimframework.com/t/slim-4-slim-twig-render-impossible/3476>\
**Category:** Questions\
**Created:** [September 25, 2019, 8:03pm UTC](https://discourse.slimframework.com/t/slim-4-slim-twig-render-impossible/3476 "2019-09-25T20:03:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![djo](https://avatars.discourse-cdn.com/v4/letter/d/8c91f0/32.png) [@djo](https://discourse.slimframework.com/u/djo)\
**Post date:** [September 25, 2019, 8:03pm UTC](https://discourse.slimframework.com/t/slim-4-slim-twig-render-impossible/3476/1 "2019-09-25T20:03:31Z")

</div>

Good morning all

after a lot of search on the forum and google  
and the doc of slim v4 impossible to display my templates I would like your light big thank you. (even if the subject has already been mentioned)

```
Container.php

```

![09](https://canada1.discourse-cdn.com/flex030/uploads/slimframework/original/1X/0e85335868cf4a2af21c6d728cd2f482609c5387.png)

frontController.php  
 ![26](https://canada1.discourse-cdn.com/flex030/uploads/slimframework/original/1X/7fefedb80967a5814dc232f90312184047eb73dd.png)

error

 ![47](https://canada1.discourse-cdn.com/flex030/uploads/slimframework/original/1X/0a567cb2ae7661f8aff59ebd52bd44ba91f1f892.png)

---

<div class="post-metadata">

**Author:** ![Antnee](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@Antnee](https://discourse.slimframework.com/u/Antnee)\
**Post date:** [September 25, 2019, 8:58pm UTC](https://discourse.slimframework.com/t/slim-4-slim-twig-render-impossible/3476/2 "2019-09-25T20:58:16Z")

</div>

Hi @djo, welcome! 👋

The simple answer is that you’re trying to call the `render()` method on `$this->view`, but if you notice you haven’t defined it in your constructor. You have two choices:

1. Add a `private $view;` property at the top of your class and in your constructor add `$this->view = $container->get('view');` (working from memory, but I _think_ that’s right)
2. Or, in your `homePage()` method, change `$this->view->render()` to `$this->container->get('view')->render()`

There’s a bigger piece where we don’t recommend that you inject the entire container, preferring to inject the dependencies themselves, but you appear to be using larger controllers, rather than dedicated action classes, so that will be a bit laborious. Also, if you’re using a container that supports auto-wiring (it looks like you’re using PHPDI, which does), you won’t get the best from it this way.

This is for another topic, though 🙂

I hope that helps.

---

<div class="post-metadata">

**Author:** ![djo](https://avatars.discourse-cdn.com/v4/letter/d/8c91f0/32.png) [@djo](https://discourse.slimframework.com/u/djo)\
**Post date:** [September 26, 2019, 1:06am UTC](https://discourse.slimframework.com/t/slim-4-slim-twig-render-impossible/3476/3 "2019-09-26T01:06:39Z")

</div>

hello Antee  
thanks for your help really  
and I take note for the container  
I started on slim but thanks for the advice
