PHPackages                             dingo-d/php-mjml-renderer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. dingo-d/php-mjml-renderer

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

dingo-d/php-mjml-renderer
=========================

PHP renderer for MJML language

1.0.0(6mo ago)2121[2 issues](https://github.com/dingo-d/php-mjml-renderer/issues)[1 PRs](https://github.com/dingo-d/php-mjml-renderer/pulls)MITPHPPHP &gt;=8.3CI passing

Since Nov 3Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/dingo-d/php-mjml-renderer)[ Packagist](https://packagist.org/packages/dingo-d/php-mjml-renderer)[ Docs](https://github.com/dingo-d/php-mjml-renderer)[ RSS](/packages/dingo-d-php-mjml-renderer/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

MJML Renderer for PHP
=====================

[](#mjml-renderer-for-php)

[![CI Checks](https://github.com/dingo-d/php-mjml-renderer/actions/workflows/ci.yml/badge.svg)](https://github.com/dingo-d/php-mjml-renderer/actions/workflows/ci.yml)[![PHP Version](https://camo.githubusercontent.com/cc97d1704e296425217e5e7e68c9d0aaade6ed28d7e875ada3a60f76feddea2e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f64696e676f2d642f7068702d6d6a6d6c2d72656e64657265722f7068702e737667)](https://packagist.org/packages/dingo-d/php-mjml-renderer)[![GitHub License](https://camo.githubusercontent.com/8ae49d4cb7d80b44ecb45232d9eca3f390b265d769559232b43fae1276163f56/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f64696e676f2d642f7068702d6d6a6d6c2d72656e6465726572)](https://camo.githubusercontent.com/8ae49d4cb7d80b44ecb45232d9eca3f390b265d769559232b43fae1276163f56/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f64696e676f2d642f7068702d6d6a6d6c2d72656e6465726572)

A pure PHP implementation of the MJML rendering engine. Convert MJML markup to responsive HTML emails without requiring Node.js or external APIs.

Why?
----

[](#why)

Existing PHP MJML libraries rely on either:

- The official MJML API (requires external service)
- Node.js executable (requires Node.js installation)

This library is a **pure PHP implementation** that renders MJML to HTML entirely in PHP, with no external dependencies beyond PHP itself.

Features
--------

[](#features)

### Complete MJML Support

[](#complete-mjml-support)

All 27 standard MJML elements are fully implemented:

**Head Components:**

- `` - Document head wrapper
- `` - Email title
- `` - Preview text
- `` - External font imports
- `` - Custom CSS styles
- `` - Responsive breakpoint configuration
- `` - Global attribute defaults
- `` - Custom HTML attributes

**Layout Components:**

- `` - Email body wrapper
- `` - Horizontal sections
- `` - Columns within sections
- `` - Full-width background wrapper
- `` - Non-stacking column groups
- `` - Hero image with overlay content

**Content Components:**

- `` - Text content
- `` - Call-to-action buttons
- `` - Responsive images
- `` - Horizontal dividers
- `` - Vertical spacing
- `` - HTML tables with MJML styling

**Interactive Components:**

- `` + children - Collapsible FAQ sections
- `` + children - Image carousels
- `` + children - Navigation menus
- `` + children - Social media icons

**Utility Components:**

- `` - Raw HTML passthrough
- `` - File inclusion

### Modern PHP

[](#modern-php)

- PHP 8.1+ with strict types
- PSR-12 coding standards
- PHPStan level 9 static analysis
- Comprehensive test coverage

### Performance

[](#performance)

Excellent rendering performance:

- Simple emails: ~0.3ms average
- Complex emails: ~1.2ms average
- Large emails (10+ sections): ~2.8ms average
- Parsing: ~0.03ms average

Installation
------------

[](#installation)

```
composer require dingo-d/php-mjml-renderer
```

Usage
-----

[](#usage)

### Basic Example

[](#basic-example)

```
