a3gz/chubby-view
Composer 安装命令:
composer require a3gz/chubby-view
包简介
PHP Renderer for Chubby
README 文档
README
PHP Renderer for Chubby.
Chubby View is a PHP renderer that facilitates a very handy way of rendering views with Slim.
A template
class DefaultTemplate extends \Chubby\View\Template
{
/**
* @var array
*/
protected $components = [
'header' => 'src/app/views/components/header.php',
'footer' => 'src/app/views/components/footer.php',
];
/**
* @var string
*/
protected $template = 'src/app/views/templates/default-template.php';
} // class
src/app/views/templates/default-template.php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<chubby-styles></chubby-styles>
</head>
<body>
<?php $this->render('header'); ?>
<?php $this->render('content'); ?>
<?php $this->render('footer'); ?>
<chubby-scripts></chubby-scripts>
</body>
</html>
How to use
$tpl = new \Templates\DefaultTemplate('path/to/templates');
// The component path here is relative,
// to th path/to/template given in the constructor
$tpl->define('content', 'src/app/views/components/hello')
->setData(['name' => $name])
->write( $response );
// It's also possible to use aboslute paths by adding a leading
// slash:
$tpl->define('content', '/abs/path/to/src/app/views/components/hello')
->setData(['name' => $name])
->write( $response );
src/app/views/components/hello.php
<chubby-scripts>
<script>
console.log('Hello', '<?php echo $this->name; ?>');
</script>
</chubby-scripts>
<chubby-styles>
<style>
.hello strong {
color: blue;
font-size: 16px;
}
.bye strong {
color: green;
}
</style>
</chubby-styles>
<div class="hello">
<strong><?php echo "Hello {$this->name}"; ?></strong>
</div>
<div class="bye">
<strong><?php echo "Bye"; ?></strong>
</div>
Resulting HTML file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
.hello strong {
color: blue;
font-size: 16px;
}
.bye strong {
color: green;
}
</style>
</head>
<body>
<header>
<h1>Welcome to Chubby 2</h1>
<strong>An application template for Slim 3</strong>
</header>
<div class="hello">
<strong>Hello world</strong>
</div>
<div class="bye">
<strong>Bye</strong>
</div>
<footer>
by <a href="https://www.roetal.com">Alejandro Arbiza</a>
</footer>
<script>
console.log('Hello', 'world');
</script>
</body>
</html>
a3gz/chubby-view 适用场景与选型建议
a3gz/chubby-view 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.05k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 07 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「template」 「view」 「render」 「slim」 「chubby」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 a3gz/chubby-view 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 a3gz/chubby-view 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 a3gz/chubby-view 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
Illuminate View for Morningmedley.
Blade template for Kirby
Render small SVG icons to monochrome ANSI for terminal UIs (Laravel/Prompts, Symfony Console, plain CLI).
Common Render Api Interface
Simple ASCII output of array data
统计信息
- 总下载量: 1.05k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-07-24