PHPackages                             evanschleret/lara-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. [Templating &amp; Views](/categories/templating)
4. /
5. evanschleret/lara-mjml

ActiveLibrary[Templating &amp; Views](/categories/templating)

evanschleret/lara-mjml
======================

Just a service provider for Spatie's MJML wrapper

v1.0.0(1mo ago)1722.0k↓25.6%[1 PRs](https://github.com/EvanSchleret/lara-mjml/pulls)MITPHPPHP ^8.2 || ^8.3 || ^8.4 || ^8.5CI passing

Since Jul 23Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/EvanSchleret/lara-mjml)[ Packagist](https://packagist.org/packages/evanschleret/lara-mjml)[ Docs](https://github.com/evanschleret/lara-mjml)[ GitHub Sponsors](https://github.com/EvanSchleret)[ RSS](/packages/evanschleret-lara-mjml/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (15)Versions (10)Used By (0)

 [![LaraMJML banner](.github/assets/banner.png)](.github/assets/banner.png)

LaraMJML
========

[](#laramjml)

 MJML rendering for Laravel Blade emails with a dedicated view engine, configurable MJML options, and predictable output for Mailables and Notifications.

 [![Packagist Version](https://camo.githubusercontent.com/a47087ec5977b2ff4ae42aa3ae0a202d0be98be7c3ab2445bc8b757e033aaba3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6576616e7363686c657265742f6c6172612d6d6a6d6c3f6c6162656c3d7061636b6167697374)](https://packagist.org/packages/evanschleret/lara-mjml) [![Packagist Downloads](https://camo.githubusercontent.com/397e6d20c3d8e834d136b3331cce405180e7c45038fffb069366299bf0d71bde/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6576616e7363686c657265742f6c6172612d6d6a6d6c)](https://packagist.org/packages/evanschleret/lara-mjml) [![License](https://camo.githubusercontent.com/19782ae33e6e9179d333fd7ae669b7a225a67be5fbb78ff0622abb14938adb61/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6576616e7363686c657265742f6c6172612d6d6a6d6c)](https://packagist.org/packages/evanschleret/lara-mjml) [![Tests](https://github.com/EvanSchleret/lara-mjml/actions/workflows/run-tests.yml/badge.svg)](https://github.com/EvanSchleret/lara-mjml/actions/workflows/run-tests.yml) [![PHP >= 8.2](https://camo.githubusercontent.com/31a67572ee10d23c041c57eb58d5388aadcb63dfdc64932af8bcd2ecf6470b92/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344382e322d373737424234)](https://camo.githubusercontent.com/31a67572ee10d23c041c57eb58d5388aadcb63dfdc64932af8bcd2ecf6470b92/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344382e322d373737424234) [![Laravel 12.x | 13.x](https://camo.githubusercontent.com/fd6d9944c001a3eb844b08cf10b2fd294740921d358a48bbf7dff0cbf2b7d648/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31322e7825323025374325323031332e782d464632443230)](https://camo.githubusercontent.com/fd6d9944c001a3eb844b08cf10b2fd294740921d358a48bbf7dff0cbf2b7d648/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31322e7825323025374325323031332e782d464632443230)

Why LaraMJML
------------

[](#why-laramjml)

LaraMJML gives you a focused way to render MJML in Laravel without changing your email workflow:

- keeps Laravel Blade as the template layer
- compiles `.mjml.blade.php` layouts through an MJML view engine
- supports MJML runtime options from Laravel config
- works with Mailables and Notifications
- keeps rendering behavior deterministic across environments

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

[](#requirements)

- PHP `>=8.2`
- Laravel `12.x` or `13.x`
- Node.js runtime with the `mjml` package installed

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

[](#installation)

Install the package:

```
composer require evanschleret/lara-mjml
```

Install MJML in your Laravel app:

```
npm install mjml
```

Publish the package config (optional):

```
php artisan vendor:publish --provider="EvanSchleret\LaraMjml\Providers\LaraMjmlServiceProvider"
```

Quick start
-----------

[](#quick-start)

Create an MJML layout:

```

        @yield('content')

```

Save it as:

```
resources/views/layouts/base.mjml.blade.php

```

Create your email view with regular Blade inheritance:

```
@extends('layouts.base')

@section('content')
  Hello {{ $userName }}
@endsection
```

Save it as:

```
resources/views/emails/welcome.blade.php

```

Blade file rules
----------------

[](#blade-file-rules)

Use this hierarchy to avoid malformed MJML:

- the layout contains `` and ``
- the layout filename includes `.mjml.blade.php`
- child views extend the MJML layout
- child views do not include `.mjml` in the filename

Correct:

```
resources/views/layouts/base.mjml.blade.php
resources/views/emails/welcome.blade.php

```

Incorrect:

```
resources/views/layouts/base.mjml.blade.php
resources/views/emails/welcome.mjml.blade.php

```

Use with Mailable
-----------------

[](#use-with-mailable)

```
