carbontwelve / slim-plates
A Pimple service provider for including php-plates into slim3
0.0.4
2016-04-19 11:25 UTC
Requires
- league/plates: ^3.1
- slim/slim: ^3.1
This package is auto-updated.
Last update: 2024-11-07 15:54:42 UTC
README
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.
Getting started
The easiest method of getting started is to include this library via composer:
composer require carbontwelve/slim-plates
Example usage with Slim 3
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();
Example usage with any PSR-7 project
$yourData = []; $platesRenderer = new Carbontwelve\SlimPlates\PlatesRenderer('./path/to/templates', 'phtml'); $response = $platesRenderer->render(new Response(), 'template', $yourData)
Not invented here
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.