PHPackages                             kcs/mjml - 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. kcs/mjml

ActivePhp-ext[Mail &amp; Notifications](/categories/mail)

kcs/mjml
========

v1.2.1(2mo ago)71.0k↑300%2MITRustCI passing

Since May 5Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/alekitto/mjml-php)[ Packagist](https://packagist.org/packages/kcs/mjml)[ RSS](/packages/kcs-mjml/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (7)DependenciesVersions (5)Used By (0)

mjml-php
========

[](#mjml-php)

[![Docs](https://camo.githubusercontent.com/ab411fcc4e66226ab8aacb7043a0ac4aa64ecc4c09a43470baa9069c0bb60385/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f63732d6d6b646f63732d626c7565)](./docs/index.md)

PHP extension that embeds [MRML](https://github.com/jdrouet/mrml), the [MJML](https://mjml.io) rendering engine written in Rust, so that you can render MJML templates directly from PHP without shelling out to a CLI tool.

Documentation
-------------

[](#documentation)

The full documentation lives under [`./docs/`](./docs/index.md) and is published as a MkDocs site. Start with the [architecture overview](./docs/index.md) and consult the dedicated guides for [installation](./docs/installation.md), [configuration](./docs/configuration.md), [usage](./docs/usage.md), [API details](./docs/api.md), and [troubleshooting](./docs/troubleshooting.md).

To preview the site locally install MkDocs and run:

```
composer run docs:serve
```

This command proxies to `mkdocs serve` using the navigation defined in [`mkdocs.yml`](./mkdocs.yml).

Overview
--------

[](#overview)

- **Native MJML rendering** – compile templates into responsive HTML emails through a thin PHP wrapper around the Rust engine.
- **File and stream support** – render inline strings or files (including stream wrappers) through `render` and `renderFile`.
- **Configurable output** – control comments, custom fonts, and social icon URLs via constructor options.
- **Exceptions-first API** – failed renders surface as `Mjml\Exception\RenderException`, enabling straightforward error handling.

Requirements
------------

[](#requirements)

- PHP **8.0 or newer** with the development headers (`php-dev`, `php-devel`, or similar).
- [Rust](https://www.rust-lang.org/) toolchain with **Cargo** available in `PATH` (the build uses `cargo build`).
- Build dependencies required by MRML, for example `build-essential`, `gcc`, `make`, `libclang-dev`, `openssl`, `libssl-dev`, and `git`.
- `phpize` and `php-config` from your PHP installation.

> **Note:** On Alpine Linux install `php-dev`, `cargo`, `clang-dev`, `openssl-dev`, and `build-base`. On Debian/Ubuntu use `apt install php-dev rustc cargo build-essential libclang-dev libssl-dev`.

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

[](#installation)

### Build from source

[](#build-from-source)

```
phpize
./configure            # add --enable-cargo-debug to build a debug artefact
make
sudo make install      # installs mjml.so into the active PHP extension dir
```

After installation, enable the extension in your `php.ini` (see [Configuration](#configuration)). During development you can load the module from the build tree instead of running `make install`:

```
php -dextension=./target/release/mjml.so your-script.php
```

### Composer / packaged distribution

[](#composer--packaged-distribution)

The project is published as a Composer package (`kcs/mjml`). You can pull the extension into your project with:

```
pie install kcs/mjml
```

PIE will place the extension artefact under the PHP extension directory (and enable it, if possible).

### Configuration

[](#configuration)

Add one of the following lines to your PHP configuration:

```
; system-wide configuration
extension=mjml

; or provide an absolute path when running from the build tree
extension=/path/to/mjml-php/target/release/mjml.so
```

When using PHP-FPM or Apache, restart the service so the new module is loaded.

Usage
-----

[](#usage)

```
