cherry-project/templater
Composer 安装命令:
composer require cherry-project/templater
包简介
Cherry-project Template Engine
关键字:
README 文档
README
The Cherry-project Template wrapper
Including
Install from composer composer require cherry-project/templater
Include Autoloader in your main file (Ex.: index.php)
require_once __DIR__ . '/vendor/autoload.php';
Class Templater
Import class
use Cherry\Templating\Templater;
Crete class new object
$templateEngine = new Templater(PATH_TO_TEMPLATES);
Where PATH_TO_TEMPLATES is path to your templates folder. Ex.: __DIR__ . '/../examples/templates'
Create new template in you'r templates folder (Ex.: index.templater.php) which contains simple HTML
Markup with PHP:
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Hello, World!</title> </head> <body> <h1>Hello, {{ name }}!</h1> </body> </html>
Then you can call $templateEngine objects render method with two arguments:
- Name of rendering template
- Arguments (PHP Variables) for template
Arguments is simple PHP Array:
$args = [ 'name' => 'Name 1', 'surname' => 'Surname 1' ];
Our index.templater.php template contains only one PHP Variable $name, so we must pass it in render method:
$response = $templateEngine->render('index.templater.php', [ 'name' => 'Temuri' ]);
After that $response Variable will contain Response object and we can print it:
echo $response;
In first argument of render method we can put full filename of template (index.templater.php)
or only template name (name without file extension Ex.: index)
2019 © Cherry-project
cherry-project/templater 适用场景与选型建议
cherry-project/templater 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 62 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 03 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「templating」 「cherry」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 cherry-project/templater 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cherry-project/templater 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 cherry-project/templater 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
A Processor for Markup written in PHP. Allows extraction of Markup into a data structure, orchestrated nested manipulation of said structure, and output as (optimized) Markup.
Melis Platform Templating Plugin Creator
Serpent is a lightweight and compiling templating engine for PHP. It was designed to seamlessly integrate into existing MVC frameworks. It uses PHP itself as its template language, so you do not need to learn a new markup language. On the other side you get many improvements compared to pure PHP.
The template engine.
Template language for PHP
统计信息
- 总下载量: 62
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-03-29