$app->get('/', 'App\Controllers\UserController:listUsers');
$container['UserController'] = function($container) {
return new App\Controllers\UserController($container);
};
$app->get('/', 'UserController:listUsers');
<?php
namespace App\Controllers;
class UserController{
private $container = null;
public function __construct($container) {
$this->container = $container;
}
public function listUsers($request, $response){
return $this->container->view->render($response, 'home.twig');
}
}
$container[App\WidgetController::class] = function ($c) {
$view = $c->get('view');
$logger = $c->get('logger');
$table = $c->get('db')->table('table_name');
return new \App\WidgetController($view, $logger, $table);
};