seeren/controller

Manage action for http message

4.1.0 2022-01-08 14:09 UTC

This package is auto-updated.

Last update: 2024-04-08 19:31:05 UTC


README

Build Require Coverage Download CodacyVersion

Manage action for http message

Installation

composer require seeren/controller

Seeren\Controller\JsonController

Retrieve PSR-7 Response for JSON format

use Seeren\Controller\JsonController;

$controller = new JsonController();
$response = $controller->render(['foo' => 'bar']);

Seeren\Controller\HTMLController

Retrieve PSR-7 Response for HTML format

use Seeren\Controller\HTMLController;

$controller = new HTMLController();
$response = $controller->render('template.html.php', [
    'title' => 'Hello World'
]);

By default, templates folder is in /templates and include path can be specified at construction

project/
└─ templates/

Template use PHP syntax and values are sanitized by default

<h1><?= $title ?></h1>

License

This project is licensed under the MIT License