rnr1721/le7-view
Composer 安装命令:
composer require rnr1721/le7-view
包简介
View module for le7 PHP framework or any PSR PHP project
README 文档
README
Base View component for le7 framework or any PHP projects.
You can install any of this in any PHP 8 PSR project.
Requirements
- PHP 8.1 or higher.
- Composer 2.0 or higher.
What it can?
- AssetsCollection object for manage collections of JS and CSS
- WebPage object for store webpage header and scripts data
- ViewTrait that part of any view adapter for le7-framework
Installation
This component is dependency for this projects:
- https://github.com/rnr1721/le7-view-twig - Twig renderer
- https://github.com/rnr1721/le7-view-smarty - Smarty renderer
- https://github.com/rnr1721/le7-view-php - PHP renderer
You must install one of them to use it, but...
composer require rnr1721/le7-view
Testing
composer test
AssetsCollection
This is great tool to manage assets collection. It can be controlled by special setter methods or you can set configuration array into constructor.
Example of configuration:
$styles = [ 'bootstrap5' => 'https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css' ]; $scripts = [ 'axios' => [ // You can define with params as need 'script' => 'https://cdnjs.cloudflare.com/ajax/libs/axios/1.4.0/axios.min.js', 'params' => 'defer' ], // Or you can define scripts directly 'jquery' => 'https://code.jquery.com/jquery-3.7.0.min.js', 'vuejs' => 'https://cdn.jsdelivr.net/npm/vue@2.7.8/dist/vue.js', 'bootstrap5' => 'https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.min.js' ]; $collections = [ 'mycollection' => [ 'scripts_header' => [ 'vuejs' ], 'scripts_footer' => [ ], 'styles' => [ 'bootstrap5' ] ] ];
NOTE: Now you can use "variables" in CDN: URLs for local places: {url}, {libs}, {js}, {css} example: {url}/libs/jquery.js
Now, we can create instance of AssetsCollectionGeneric (implements AssetsCollectionInterface):
use Core\View\AssetsCollectionGeneric; $ac = new AssetsCollectionGeneric($scripts, $styles, $collections);
Methods for setting scripts
setStyle
You can set new style to styles library:
$ac->setStyle('bootstrap5', 'https://link_to_bootstrap5.css');
setScript
You can set new scripts to styles library:
$params = 'defer' // Not-required $ac->setScript('bootstrap5', 'https://link_to_bootstrap5.js', $params);
setCollection
You can set new collection to styles library: For example, we need collection, where will be vuejs JS and bootstrap5 CSS: Of course, all scripts with keys need to be defined before.
// Add to header $ac->setCollection('mycollection', ['vuejs'], [], ['bootstrap5']); // Add to footer $ac->setCollection('mycollection', [], ['vuejs'], ['bootstrap5']);
WebPage object
WebPage object collects various information about web page and you can use in in webpage template - scripts, styles, meta-tags, import maps, title, description, keywords etc.
ViewTopology object
ViewTopology needs to store base paths and urls.
rnr1721/le7-view 适用场景与选型建议
rnr1721/le7-view 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 217 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 03 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「view」 「component」 「le7」 「le7-framework」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rnr1721/le7-view 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rnr1721/le7-view 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rnr1721/le7-view 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
Shoot aims to make providing data to your templates more manageable
FSi DataSource Component
Illuminate View for Morningmedley.
Priveate for SkeekS CMS
Blade template for Kirby
统计信息
- 总下载量: 217
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 7
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-03-12