codeat3/inlinestyle
Composer 安装命令:
composer require codeat3/inlinestyle
包简介
Apply CSS stylesheets directly as inline styles to a HTML document
README 文档
README
This is a fork of the original repository (christiaan/InlineStyle)[https://github.com/christiaan/InlineStyle] by Christiaan Baartse
InlineStyle provides an easy way to apply embedded and external stylesheets directly as inline styles on the HTML tags. This is especially targetted at mail clients which mostly dont support stylesheets but do support the style attribute for HTML tags.
Installation
composer require inlinestyle/inlinestyle
Or add the following to your composer.json file
"require": {
"inlinestyle/inlinestyle": "^2.0"
}
Usage
Use composer to download required dependencies.
Import InlineStyle
use \InlineStyle\InlineStyle;
Create a new InlineStyle object from either a HTML string or HTML file.
$htmldoc = new InlineStyle("testfiles/test.html");
or
$htmldoc = new InlineStyle(file_get_contents("http://github.com"));
Apply the embedded and external stylesheets
First we'll have to extract the stylesheets from the document and then we have to apply them.
$htmldoc->applyStylesheet($htmldoc->extractStylesheets());
The second param is the base url that is used to parse the links to external stylesheets.
$htmldoc->applyStylesheet($htmldoc->extractStylesheets(null, "http://github.com"));
Applying additional stylesheets
This class can also be used to apply a given css template to each processed HTML file.
$htmldoc->applyStylesheet(file_get_contents("testfiles/external.css"));
Retrieving the modified HTML
After calling applyStylesheet various times the resulting HTML can be retrieved as a string using getHTML.
$html = $htmldoc->getHTML();
codeat3/inlinestyle 适用场景与选型建议
codeat3/inlinestyle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 73.74k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 09 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「css」 「email」 「inline」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 codeat3/inlinestyle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 codeat3/inlinestyle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 codeat3/inlinestyle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Symfony bundle for using the CssToInlineStyles translator by tijsverkoyen
A Twig extension to insert css as inline styles with a tag
A Laravel Nova field for displaying morphTo relationship inline.
Caching and compression for Twig assets (JavaScript and CSS).
Utility functions to inline SVGs in PHP Projects
Inline test plugin for the Testo testing framework.
统计信息
- 总下载量: 73.74k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 32
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-09-06