romanzaycev/tooolooop
Composer 安装命令:
composer require romanzaycev/tooolooop
包简介
PHP7 lightweight native template engine
README 文档
README
PHP7 lightweight native templates.
Installation
via Composer:
composer require romanzaycev/tooolooop
Usage
<?php declare(strict_types = 1); require "vendor/autoload.php"; use Romanzaycev\Tooolooop\Engine; $engine = new Engine(__DIR__ . '/views'); $template = $engine->make('page'); $template->assign(['text' => 'Lorem ipsum']); echo $template->render();
views/page.php:
<?php $this->extend('layout') ?> <section> <?=$this->e($text)?> </section> <?php $this->start('footer') ?> <footer> Some footer content. </footer> <?php $this->end() ?>
views/layout.php:
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Example</title> </head> <body> <main> <h1>Example</h1> <?=$this->block('content')?> </main> <?=$this->block('footer')?> </body> </html>
Need more examples?
Requires
PHP >= 7.2.0
Extending library
PSR-11 container support
You can use a PSR-11 compatible container and inject dependencies into objects that are generated inside the library (Scope):
<?php use Romanzaycev\Tooolooop\Engine; use Psr\Container\ContainerInterface; /** @var ContainerInterface $container */ $container = ...; // Initialize PSR-11 container // and define implementation of Romanzaycev\Tooolooop\Scope\ScopeInterface $engine = new Engine(__DIR__ . '/views'); $engine->setContainer($container); $template = $engine->make('page'); // <-- Scope in this template will be obtained from container
You can define the implementation of Romanzaycev\Tooolooop\Scope\ScopeInterface in the
container configuration and engine instances Scope through it.
⚠️ ATTENTION! Make sure that the container returns a new instance of Scope all time! Cached Scope instance does not work.
User scope
Otherwise, you can specify a custom implementation of the class via $engine->setScopeClass():
<?php use Romanzaycev\Tooolooop\Engine; use Romanzaycev\Tooolooop\Scope\Scope; use Romanzaycev\Tooolooop\Scope\ScopeInterface; class UserSpecificScope extends Scope implements ScopeInterface { // Implement your additions, ex. widget system :-) } $engine = new Engine(__DIR__ . '/views'); $engine->setScopeClass(UserSpecificScope::class);
Testing
composer run test
romanzaycev/tooolooop 适用场景与选型建议
romanzaycev/tooolooop 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 158 次下载、GitHub Stars 达 2, 最近一次更新时间为 2017 年 12 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「templating」 「templates」 「views」 「romanzaycev」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 romanzaycev/tooolooop 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 romanzaycev/tooolooop 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 romanzaycev/tooolooop 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
CakePHP 4.x AdminLTE Theme.
The tenancy/tenancy views mutations
Bookdown.io With Bootswatch Styles And Prism Syntax Highlighting
The "View Counter" bundle
CakePHP 3.x Gentelella Theme.
统计信息
- 总下载量: 158
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 6
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-12-09