Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Use MJML API with notfloran/mjml-bundle

Use MJML API with notfloran/mjml-bundle

$ composer require juanmiguelbesada/mjml-php
<?php
# src/Mjml/ApiRenderer.php
namespace App\Mjml;
use Mjml\Client;
use NotFloran\MjmlBundle\Renderer\RendererInterface;
class ApiRenderer implements RendererInterface
{
/**
* @var Client
*/
private $client;
public function __construct(Client $client)
{
$this->client = $client;
}
public function render(string $mjmlContent): string
{
return $this->client->render($mjmlContent);
}
}
# config/packages/mjml.yaml
mjml:
renderer: 'service'
options:
service_id: 'App\Mjml\ApiRenderer'
# config/services.yaml
services:
mjml_api:
class: Mjml\Client
arguments:
- 'application-id'
- 'secret-key'
App\Mjml\ApiRenderer:
arguments:
- '@mjml_api'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.