I have a class abastrata I hold the controller, that way I can call any container directly only using $ this-> namecontroller it is right to do, can bring a problem of performace?
------------------------------------------ Controller.php -----------------------------------
<?php namespace App\Action; use Slim\Container; abstract class Controller { protected $container; /* @var \Smarty $view*/ /* @var \App\Model\Loja $loja*/ /* @var \App\Model\Produto $produto*/ /* @var \App\Model\Banner $banner*/ /* @var \App\Model\Departamento $departamento*/ /* @var \App\Model\Paginacao $pager*/ /* @var \App\Model\Rating $rating*/ public function __construct(Container $container) { $this->container = $container; $smarty = $this->view->getSmarty(); $smarty->assign('menu', $this->loja->getMenu()); $smarty->assign('loja', $this->loja->getLoja()); $smarty->assign('cart', $this->loja->getCart()); } public function __get($key) { if ($this->container->has($key)) { return $this->container->{$key}; } } } ------------------------------------------ Produto.php ----------------------------------- <?php namespace App\Action; use App\Helper\Google; final class ProdutoAction extends Controller { public function dispatch($request, $response, $args) { $produto = $this->produto->getProduto($args['id']); $rating = $this->rating->getRating($args['id']); } } $container['App\Action\ProdutoAction'] = function ($c) { return new App\Action\Produto($c); };