Skip to content

A container interop service provider for including php-plates into any interop compliant framework

License

Notifications You must be signed in to change notification settings

carbontwelve/slim-plates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Slim3 Plates Service Provider

styleci Latest Version Software License ghit.me

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.

About

A container interop service provider for including php-plates into any interop compliant framework

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages