This package contains a container interop compatible service provider and a renderer for rendering php plates view scripts into a PSR-7 responsive object. It works well with version 3 of the Slim framework.
The easiest method of getting started is to include this library via composer:
composer require carbontwelve/slim-plates
use Carbontwelve\SlimPlates\PlatesViewProvider;
include "vendor/autoload.php";
$app = new Slim\App(
new \Slim\Container([
'renderer' => [
'template_path' => realpath(__DIR__.'/views'),
'template_ext' => 'phtml'
]
])
);
$container = $app->getContainer();
$container->register(new Carbontwelve\SlimPlates\PimplePlatesViewProvider());
$app->get('/hello/{name}', function ($request, $response, $args) {
return $this->renderer->render($response, "/hello.phtml", $args);
});
$app->run();
$yourData = [];
$platesRenderer = new Carbontwelve\SlimPlates\PlatesRenderer('./path/to/templates', 'phtml');
$response = $platesRenderer->render(new Response(), 'template', $yourData)
This project was something I put together to meet my own needs and as way of learning git. There are a couple of alternatives that you might want to investigate.