Или так:
require __DIR__ . '/vendor/autoload.php';
use Symfony\Component\HttpFoundation\Response;
class Model
{
public function getData()
{
return "MVC example\n";
}
}
class View
{
public function render($data)
{
return new Response($data);
}
}
class Controller
{
private $model;
private $view;
public function __construct(Model $model, View $view)
{
$this->model = $model;
$this->view = $view;
}
public function handle()
{
return $this->view->render($this->model->getData());
}
}
$config = [
'routing' => [
'routes' => [
'home' => [
'method' => 'GET',
'path' => '/',
'handler' => Controller::class . ':handle',
],
],
],
'container' => [
'use_autowiring' => true,
],
];
(new Vermillion\Http\Application($config))->run();