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

ActiveSymfony-bundle[Mail &amp; Notifications](/categories/mail)

notfloran/mjml-bundle
=====================

Symfony bundle for MJML

v3.10.0(1mo ago)1142.1M—6.6%22[2 issues](https://github.com/notFloran/mjml-bundle/issues)[2 PRs](https://github.com/notFloran/mjml-bundle/pulls)2MITPHPPHP &gt;=7.1.0CI passing

Since Nov 7Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/notFloran/mjml-bundle)[ Packagist](https://packagist.org/packages/notfloran/mjml-bundle)[ RSS](/packages/notfloran-mjml-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (15)Versions (34)Used By (2)

MjmlBundle
==========

[](#mjmlbundle)

[![Latest Stable Version](https://camo.githubusercontent.com/6c10e4fdd718d1590eae7c4d2c3a3c90b617e62e9d68cf643b73d7444732f619/68747470733a2f2f706f7365722e707567782e6f72672f6e6f74666c6f72616e2f6d6a6d6c2d62756e646c652f762f737461626c652e737667)](https://packagist.org/packages/notfloran/mjml-bundle)[![Latest Unstable Version](https://camo.githubusercontent.com/5937e0855e9df00896a6bf5a946809f2849089edfcce885cda43f808f0693493/68747470733a2f2f706f7365722e707567782e6f72672f6e6f74666c6f72616e2f6d6a6d6c2d62756e646c652f762f756e737461626c652e737667)](https://packagist.org/packages/notfloran/mjml-bundle)

Bundle to use [MJML](https://mjml.io/) 3 and 4 with Symfony &gt;= 3.

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

[](#installation)

### Applications that use Symfony Flex

[](#applications-that-use-symfony-flex)

Open a command console, enter your project directory and execute:

```
$ composer require notfloran/mjml-bundle
```

### Applications that don't use Symfony Flex

[](#applications-that-dont-use-symfony-flex)

#### Step 1: Download the Bundle

[](#step-1-download-the-bundle)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

```
$ composer require notfloran/mjml-bundle
```

This command requires you to have Composer installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md)of the Composer documentation.

#### Step 2: Enable the Bundle

[](#step-2-enable-the-bundle)

Then, enable the bundle by adding it to the list of registered bundles in the `app/AppKernel.php` file of your project:

```
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            // ...
            new NotFloran\MjmlBundle\MjmlBundle(),
        ];

        // ...
    }

    // ...
}
```

Renderer
--------

[](#renderer)

The default renderer is **binary**, which uses the official MJML Node.js implementation.

The **mjml-php** (PHP extension) renderer is also available as an alternative. It is based on [MRML](https://github.com/jdrouet/mrml), a third-party Rust reimplementation of MJML.

### Binary

[](#binary)

Install [MJML](https://mjml.io)

```
$ npm install mjml
```

Then you need to update the configuration:

```
# config/packages/mjml.yaml
mjml:
  renderer: binary # default: binary
  options:
    binary: '%kernel.project_dir%/node_modules/.bin/mjml' # default: mjml
    node: '/Users/user/.nvm/versions/node/v10.16.0/bin/node' # default: null
    minify: true # default: false
    validation_level: skip # default: strict. See https://mjml.io/documentation/#validating-mjml
```

The `node` option is there for those who have problems with `$PATH`, see [\#35](https://github.com/notFloran/mjml-bundle/issues/35).

Note that each render spawns a new Node.js process, which may impact performance in high-volume scenarios.

### mjml-php

[](#mjml-php)

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

Then you need to update the configuration:

```
# config/packages/mjml.yaml
mjml:
  renderer: mjml_php
```

### Custom

[](#custom)

First you must create a class which implements `NotFloran\MjmlBundle\Renderer\RendererInterface`, then declare it as a service.

And finally you have to change the configuration:

```
# config/packages/mjml.yaml
mjml:
    renderer: 'service'
    options:
        service_id: 'App\Mjml\MyCustomRenderer'
```

### PHP Config

[](#php-config)

If you're using symfony 5 and want to configure this bundle with PHP files instead of YAML:

```
// config/packages/mjml.php
