carbontwelve / slim-plates
一个将 php-plates 集成到 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-09-07 15:33:19 UTC
README
本包包含一个与 container-interop 兼容的服务提供者和一个渲染器,可以将 php plates 视图脚本渲染为 PSR-7 响应对象。它与 Slim 框架 的第 3 版很好地配合工作。
入门指南
最简单的方法是通过 composer 包含这个库
composer require carbontwelve/slim-plates
使用 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();
任何 PSR-7 项目的示例用法
$yourData = []; $platesRenderer = new Carbontwelve\SlimPlates\PlatesRenderer('./path/to/templates', 'phtml'); $response = $platesRenderer->render(new Response(), 'template', $yourData)
非原创
这个项目是我为了满足自己的需求和作为学习 git 的一种方式而创建的。有几个替代方案你可能想了解一下。