mouf/html.renderer
Composer 安装命令:
composer require mouf/html.renderer
包简介
This package contains the rendering mechanism of the Mouf framework. It is a mechanism allowing packages/templates/developers to overload a default template for various HTML objects.
关键字:
README 文档
README
What is this package?
This package contains a rendering mechanism to render objects in HTML.
For application developers
You are an application developer? Learn how to use the rendering system with PHP files or Twig templates to render your objects or overload renderers provided by packages.
See the video!
<iframe width="480" height="360" src="//www.youtube.com/embed/f2MyYSUic1U" frameborder="0" allowfullscreen></iframe>For package developers
You are a package developer? Learn how to use the rendering system to allow other users to overload your renderers easily.
Installation
$ composer require mouf/html.renderer ^2
The easiest way to use this package is through a dependency injection container compatible with container-interop/service-providers.
Once installed, you need to register the Mouf\Html\Renderer\RendererServiceProvider into your container.
If your container supports thecodingmachine/discovery integration, you have nothing to do. Otherwise, refer to your framework or container's documentation to learn how to register service providers.
Provided services
This service provider provides the following services:
| Service name | Description |
|---|---|
RendererInterface::class |
The default renderer. An alias to ChainRenderer::class |
ChainRenderer::class |
A composite renderer asking all other renderers in turn if they can render an object. |
customRenderers |
A list of RendererInterface objects at the "custom" level (top most level). This list is consumed by the ChainRenderer |
customRenderer |
A default custom renderer is provided by this package. Out of the box, template files are expected to be in the src/templates directory. |
packageRenderers |
A list of RendererInterface objects at the "package" level (bottom level). This list is consumed by the ChainRenderer. When a package you install has a renderer, it will add the renderer to this list (most of the time using the AbstractPackageRendererServiceProvider |
InitRendererFacadeMiddleware::class |
A PSR-15 middleware that is used to initialize global access to the default renderer. This is needed for the Renderable trait to work. |
Extended services
This service provider extends those services:
| Name | Compulsory | Description |
|---|---|---|
MiddlewareListServiceProvider::MIDDLEWARES_QUEUE |
yes | The InitRendererFacadeMiddleware::class registers itself in the list of PSR-15 middlewares. |
Mouf package
This package was originally part of Mouf (http://mouf-php.com), an effort to ensure good developing practices by providing a graphical dependency injection framework.
V2 makes the package framework-agnostic, so it can be used in any framework.
Basically, you will find in this package some Renderers. These are classes in charge of rendering other objects. They usually rely on template files, that contain the HTML to be rendered. Renderers can be chained, and the first renderer that knows how to render an object will be in charge of the rendering.
Troubleshooting
Your template or a custom template is not applied.
- Purge the cache with the red button in mouf.
- You use Ajax and you return html with echo (for example BCE).
- By default an echo don't apply the template to make it
- add the defaultRenderer (a class of Mouf\Html\Renderer\AutoChainRenderer) in your class
- add your templateRenderer (a class of Mouf\Html\Renderer\FileBasedRenderer) in Bootstrap this is bootstrapRenderer
- add the code before your call to the function toHTML: $this->defaultRenderer->setTemplateRenderer($this->templateRenderer);
- By default an echo don't apply the template to make it
mouf/html.renderer 适用场景与选型建议
mouf/html.renderer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 362.38k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2013 年 07 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「html」 「interface」 「tohtml」 「render」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mouf/html.renderer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mouf/html.renderer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mouf/html.renderer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This package contains the HtmlElementInterface interface that can be used to output HTML on a page. It also features base classes implementing this interface.
This package contains a set of Twig extensions and utility class to ease the use of Twig templates in Mouf.
Texy converts plain text in easy to read Texy syntax into structurally valid (X)HTML. It supports adding of images, links, nested lists, tables and has full support for CSS. Texy supports hyphenation of long words (which reflects language rules), clickable emails and URL (emails are obfuscated again
This package contains a pure PHP object representation of HTML5 tags. There is one class for each existing HTML tag, and one getter/setter per attribute.
This package contains PHP objects representing common HTML form elements, along renderers.
HTML and form generation
统计信息
- 总下载量: 362.38k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 29
- 依赖项目数: 6
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-07-20