naingaunglwin-dev/view
Composer 安装命令:
composer require naingaunglwin-dev/view
包简介
A lightweight template rendering engine with optional custom view engine integration.
README 文档
README
Simple PHP View Library
Contributing
- This is an open-source library, and contributions are welcome.
- If you have any suggestions, bug reports, or feature requests, please open an issue or submit a pull request on the project repository.
Requirement
- PHP version 8.0 or newer is required
Installation & Setup
- You can just download the code from repo and use or download using composer.
Download Using Composer
- If you don't have composer, install composer first.
- create file
composer.jsonat your project root directory. - Add this to
composer.json
{
"require": {
"naingaunglwin-dev/view": "^1.0"
}
}
- Run the following command in your terminal from the project's root directory:
composer install
- Or just run
composer require naingaunglwin-dev/viewin terminal.
Usage
- In your php file,
<?php require_once "vendor/autoload.php"; use NAL\View\View; $view = new View(__DIR__ . '/views'); // You can pass view file without extension if it is php file $view->render('index', ['status' => 'success']); // You can also render other file, // You can retrieve the view without rendering, $indexView = $view->render('index.html', [], true); // You can also render multi views $view->render(['index.html, test']);
- If you don't define your view path, View class will automatically set the view path to your project root level
Section Usage
-
create
one.phpandtwo.php -
one.php
<?php //one.php echo 'this is one.php'; $this->yield('content');
- two.php
<?php //two.php $this->extends('one'); // view file name that need to extend $this->section('content'); // Section start with `content` name echo '<br>This is section content from two.php'; $this->end('content'); // End the section `content`
- index.php
<?php require_once "vendor/autoload.php"; use NAL\View\View; $view = new View(__DIR__ . '/views'); $view->render('two');
- Output will be
this is one.php This is section content from two.php
Custom Renderer Engine
<?php $view = new \NAL\View\View('path', MyCustomEngine::class); $view->render('template'); // MyCustomEngine`s render method will be used in this process if exists
naingaunglwin-dev/view 适用场景与选型建议
naingaunglwin-dev/view 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 05 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 naingaunglwin-dev/view 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 naingaunglwin-dev/view 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-05-03