bweston92/laravel-inline-css-mailer
最新稳定版本:v0.1
Composer 安装命令:
composer require bweston92/laravel-inline-css-mailer
包简介
Laravel CSS to Inline HTML.
关键字:
README 文档
README
Installation
Just require the package and you're good to go! There is one core issue and that's Laravel doesn't allow sending plain HTML e-mails with-out it being a view, so you need to create a view file like below.
views/emails/raw.blade.php
{{ $content }}
Dependencies
This is just a wrapper for Laravel around the actual CSS inliner package found at https://github.com/tijsverkoyen/CssToInlineStyles
examples.php
class MyEmailSender {
/**
* @var \BW\L4CssInline\CssInlineMailer
*/
protected $mailer;
/**
* @param \BW\L4CssInline\CssInlineMailer $mailer
*/
public function __construct(CssInlineMailer $mailer)
{
$this->mailer = $mailer;
}
/**
* This example assumes there is a style tag in the view.
*
* @param NotificationInterface $notification
*/
public function sendNotification(NotificationInterface $notification)
{
$this->mailer->send('emails.notification', compact('notification'), function($message) use ($notification)
{
$message->to($notification->getUser()->email);
});
}
/**
* This example is passing css into the mailer.
*
* @param UserInterface $$user
*/
public function sendWelcomeEmail(UserInterface $user)
{
$this->mailer->addCss(new \BW\L4CssInline\CssCapture\RawCapture('body {background: #000;}'));
$this->mailer->send('emails.welcome-user', compact('user'), function($message) use ($user)
{
$message->to($user->email, $user->fullName);
});
}
}
Wait whats captures?
The CSS is found in multiple places, in code, local files, remote files over http, remote files ftp? This package comes with a raw capture and a file capture. Your own implementation for other methods will probably be better, just implement the capture interface.
- Raw
new \BW\L4CssInline\Capture\RawCapture('body {background: #000;}') - Local file
new \BW\L4CssInline\Capture\FileCapture('/var/www/css/styles.css')
(All the CSS in style tags will be parsed aswell)
Contributing
Just stick to the standards which is the same as Laravel's code base.
License
This package open-sourced software licensed under the MIT license
bweston92/laravel-inline-css-mailer 适用场景与选型建议
bweston92/laravel-inline-css-mailer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.53k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2015 年 02 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「mail」 「css」 「inline」 「laravel」 「premailer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 bweston92/laravel-inline-css-mailer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bweston92/laravel-inline-css-mailer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bweston92/laravel-inline-css-mailer 相关的其它包
同方向 / 同关键字的高下载量 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.
统计信息
- 总下载量: 1.53k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2015-02-19