maslosoft/miniview
Composer 安装命令:
composer require maslosoft/miniview
包简介
Mini view is minimal template rendering library with pluggable template engines. Out of the box it support plain PHP templates, Latte and Twig.
README 文档
README
Maslosoft Miniview
Quick Install
composer require maslosoft/miniview
Documentation
Minimal PHP view
PHP itself is a kind of templating language. Some other
supplemental languages have been implemented too. To
use each one of them, we need to know how to use it,
locate file exacly, and use some low-level commands like require.
Common interface
This view library provides common interface for PHP, or other templating engines, with option to extend it. Main power of miniview, is that it requires minimum code and effort to use MVC like views. It will also locate file relativelly to currently used class. It is safe to use with any functions directly outputting text, as it will capture any output and allow it to be passed anywhere, or just be displayed.
Usage
This is some example widget using MiniView:
namespace Company\SomeNamespace; use Maslosoft\MiniView\MiniView; class MyWidget { /** * View renderer * @var MiniView */ public $view = null; /** * @var string */ public $version = ''; public function __construct() { $this->view = new MiniView($this); $this->version = $this->view->getVersion(); } public function show() { return $this->view->render('myView', ['user' => 'Joe'], true); } public function greet($name) { return "Nice to meet you $name!" . PHP_EOL; } }
In view file, all widget public properties as well as methods are available using $this.
View file is located in folder views located in same folder as widget class.
Example view file:
Hello <?= $user ?>! <?= $this->greet($user);?> The version is <?= $this->version;?>
Calling show() will return rendered view file located in classFolder/views/myView.php with variable $user with value Joe.
use Company\SomeNamespace\MyWidget; require __DIR__ . '/../src/Miniview.php'; require __DIR__ . '/MyWidget.phps'; $widget = new MyWidget; echo $widget->show();
Run example
Go to examples folder and type php run.php
maslosoft/miniview 适用场景与选型建议
maslosoft/miniview 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.24k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2014 年 12 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 maslosoft/miniview 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 maslosoft/miniview 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 4.24k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 20
- 依赖项目数: 5
- 推荐数: 1
其他信息
- 授权协议: AGPL
- 更新时间: 2014-12-18