zellien/zellien-mjml 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

zellien/zellien-mjml

最新稳定版本:v1.0.1

Composer 安装命令:

composer require zellien/zellien-mjml

包简介

PHP library for rendering MJML templates

README 文档

README

PHP library for rendering MJML templates

Static Badge Static Badge

Installation

The preferred method of installation is via Composer. Run the following command to install the package and add it as a requirement to your project's

composer require zellien/zellien-mjml

Usage

Create an instance of the MjmlRenderer class by passing the configuration array to the constructor. The configuration array should contain the application_id and secret_key as non-empty strings.

Call the render method on the $renderer object, passing the MJML template as a non-empty string. It will return the rendered HTML as a non-empty string.

$mjmlTemplate = '<mjml>Your MJML template goes here</mjml>';
$renderedHtml = $renderer->render($mjmlTemplate);

Handle the potential exceptions that can be thrown by the render method:

  • BadRequestException if the request is invalid.
  • UnauthorizedException if authentication fails.
  • ForbiddenException if the request is unauthorized.
  • UnexpectedErrorException if an unexpected error occurs.
try {
    $renderedHtml = $renderer->render($mjmlTemplate);
} catch (BadRequestException $e) {
    // Handle bad request error
} catch (UnauthorizedException $e) {
    // Handle unauthorized error
} catch (ForbiddenException $e) {
    // Handle forbidden error
} catch (UnexpectedErrorException $e) {
    // Handle unexpected error
}

Additional Notes

Make sure you have the necessary dependencies installed, such as the cURL extension.

Ensure that the API URL (https://api.mjml.io/v1/render) is accessible from your environment.

That's it! You can now utilize the MjmlRenderer library in your project to render MJML templates using the API.

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-06-22