# Help-me plx \[controllers\] \[slim\]

**URL:** <https://discourse.slimframework.com/t/help-me-plx-controllers-slim/1489>\
**Category:** Questions\
**Created:** [May 13, 2017, 6:34am UTC](https://discourse.slimframework.com/t/help-me-plx-controllers-slim/1489 "2017-05-13T06:34:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adailson](https://avatars.discourse-cdn.com/v4/letter/a/cdc98d/32.png) [@adailson](https://discourse.slimframework.com/u/adailson)\
**Post date:** [May 13, 2017, 6:34am UTC](https://discourse.slimframework.com/t/help-me-plx-controllers-slim/1489/1 "2017-05-13T06:34:56Z")

</div>

I have a problem in my controller, inherit the class, controller with the following methods I will pass below, but I can not instance my route, because there are errors in container issues

> [@](#):
>
> My route:  
> $app-\>get(‘/restrita’, function ($request,$response)  
> {  
> $vars[‘page’] = ‘restrita/index’;  
> $usuario = new \App\controllers\usuarioController($container);  
> $response = $this-\>view-\>render($response,‘restrita/index.phtml’,$vars);  
> return $response;  
> })-\>setName(‘restrita’);

> [@](#):
>
> My Controller
> 
> \<?php namespace App\controllers; Class controller{ private $container; public function \_\_construct($container) { $this-\>container = $container; } public function \_\_get($property) { if($this-\>container-\>{$property}){ return $this-\>container-\>{$property}; } } }

> [@](#):
>
> class usuarioController extends controller  
> {  
> public function exibir($request,$response)  
> {  
> $usuario = usuarios::all();  
> $vars[‘usuarios’] = $usuario;  
> }  
> }

I want to call three controllers here

---

<div class="post-metadata">

**Author:** ![victor](https://avatars.discourse-cdn.com/v4/letter/v/3e96dc/32.png) [@victor](https://discourse.slimframework.com/u/victor)\
**Post date:** [May 20, 2017, 8:05am UTC](https://discourse.slimframework.com/t/help-me-plx-controllers-slim/1489/2 "2017-05-20T08:05:19Z")

</div>

You are Wrong with architecture:

**first add controller to container in dependencies.php:**

```
$container['App\controllers\usuarioController'] = function ($container) {
    return new \App\controllers\usuarioController( $container );
};

```

**Then route:**

```
$app->get('/restrita', '\App\controllers\usuarioController:exibir');

```

**In your exibir method will be:**

```
public function exibir($request,$response) {
    $usuario = usuarios::all();
    $vars['usuarios'] = $usuario;

    $this->view->render($response,'restrita/index.phtml',$vars);
}
```
