laasti / response
symfony/http-foundation 用于与模板引擎一起使用的视图响应。
v1.2.1
2016-04-13 02:27 UTC
Requires
- symfony/http-foundation: ~2.7
This package is auto-updated.
Last update: 2024-09-20 23:13:44 UTC
README
symfony/http-foundation 用于与模板引擎一起使用的视图响应。
在从 Symfony 迁移之前等待具体的 PSR-7 实现。
安装
composer require laasti/response
用法
响应器提供多种响应类型
- 原始: 直接使用内容
- 视图: 使用模板引擎渲染内容
- Json: 使用 viewdata 作为 JSON 内容
- 重定向: 重定向
- 下载: 使用文件内容并强制下载
- 流: 使用回调在输出时流式传输内容
目前,该包仅提供 PlainPHP 模板引擎。但是,未来还将添加其他引擎,欢迎建议和拉取请求。
$viewdata = new Laasti\Response\Data\ArrayData; $engine = new Laasti\Response\Engines(['/path/to/templates']); $responder = new Laasti\Response\Responder($viewdata, $engine); $responder->setData('title', 'Hello world'); $responder->setData('meta.description', 'Dummy page'); //Accessible in the template using $meta['description'] $response = $responder->view('template_name'); //Output response $response->send();
贡献
- 分叉它!
- 创建你的功能分支:
git checkout -b my-new-feature
- 提交你的更改:
git commit -am '添加一些功能'
- 推送到分支:
git push origin my-new-feature
- 提交拉取请求 :D
历史
查看 CHANGELOG.md 获取更多信息。
鸣谢
作者:Sonia Marquette (@nebulousGirl)
许可
在 MIT 许可证下发布。请参阅 LICENSE.txt 文件。