This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.
There is no license information available for the latest version (v1.2.0) of this package.

Render your MJML template on custom PHP server.

v1.2.0 2021-02-09 09:20 UTC


Integrity check

Imagine you want render your MJML template on your private PHP server, now you can.

How to install

Install this package by Composer or download manually:

composer require baraja-core/mjml-php-server

Your server must use PHP 7.1 or better and installed MJML by Node modules (internal command is /node_modules/.bin/mjml).

Server configuration

Your server must support the shell_exec() function and Apache or Ngnix.

In your root directory of webserver please configure calling this internal logic. For instance this way (most simply solution):


require __DIR__ . '/src/MjmlServer.php'; // Path to this package

$cacheDir = __DIR__ . '/cache'; // Or can be null

(new \Baraja\Mjml\MjmlServer($cacheDir))->run();

Now your MJML server is configured.

When you call URI /api/v1/mjml by HTTP request on your domain, you can render your MJML template.

API usage

API must be called by POST method with body parameter template with template.

Final template will be returned by json response.

Some example:

Call URI /api/v1/mjml with parameter:

MJML API Response example

Minimal template configuration:

                <mj-text>Hello World</mj-text>