andrewslince / slim3-mustache-view
PHP Mustache view class for Slim 3 Framework
Package info
github.com/andrewslince/slim3-mustache-view
pkg:composer/andrewslince/slim3-mustache-view
1.0.5
2016-11-27 12:34 UTC
Requires
- php: >=5.6
- mustache/mustache: ^2.11
- psr/http-message: ^1.0
Requires (Dev)
- phpunit/phpunit: 5.x
- slim/slim: ^3.0
This package is not auto-updated.
Last update: 2026-03-15 04:07:28 UTC
README
A PHP Mustache class for render views on Slim 3 Framework.
Requirements
Install
Via Composer:
$ composer require andrewslince/slim3-mustache-view
Usage
<?php $app = new \Slim\App([ // your application settings ]); // get application container $container = $app->getContainer(); // register view template engine and configurations $container['renderer'] = function () { return new \Slim\Views\Mustache([ // REQUIRED 'template' => [ // REQUIRED 'paths' => [ realpath('./templates') ], // optional 'extension' => 'html', // optional 'charset' => 'utf-8', ], // put other mustache options here¹ ]); }; // use the render() method in your application routes $app->get('/', function ($request, $response, $args) { // render your view return $this->renderer->render( $response, 'index', $args ); }); $app->run();
NOTES:
¹ See other Mustache options here.
Testing
To running unit tests, executes the command below:
./vendor/bin/phpunit -c phpunit.xml.dist
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.