Plates adapter for ResponseFactories as defined in PSR-17
The (highly) recommended way to install this package is by using Composer
composer require studiow/plates-http-factory
You will also need a package that implements PSR-17: https://packagist.org/providers/psr/http-factory-implementation
All the examples use http-interop/http-factory-guzzle.
$factory = new \Studiow\Plates\ResponseFactory(
new \League\Plates\Engine('/path/to/templates'), //the plates engine
new \Http\Factory\Guzzle\ResponseFactory() //a psr-17 compatible response factory
);
//rendering the template at /path/to/templates/pages/home.php with additional data
$response = $factory->createResponse(
'pages/home',
['title'=>'home']
);
$factory = new \Studiow\Plates\ResponseFactory(
new \League\Plates\Engine('/path/to/templates'),
new \Http\Factory\Guzzle\ResponseFactory()
);
$response = $factory->createResponse(
'error/page-not-found', //name of the template
['title'=>'Page not found!'], //data to be passed to the template
404, //http status code
'Not Found' //http reason phrase
);