{"id":25766059,"url":"https://github.com/notfloran/mjml-bundle","last_synced_at":"2025-05-15T17:04:37.973Z","repository":{"id":24843268,"uuid":"102516671","full_name":"notFloran/mjml-bundle","owner":"notFloran","description":"✉️ Symfony bundle for MJML","archived":false,"fork":false,"pushed_at":"2024-12-20T08:15:27.000Z","size":187,"stargazers_count":110,"open_issues_count":4,"forks_count":19,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-13T04:05:30.374Z","etag":null,"topics":["email","hacktoberfest","mjml","symfony","symfony-bundle"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/notFloran.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-05T18:35:37.000Z","updated_at":"2025-04-23T08:42:44.000Z","dependencies_parsed_at":"2024-01-17T09:07:54.068Z","dependency_job_id":"47b72bb4-d8a5-4505-b7c1-fb6b57054ca1","html_url":"https://github.com/notFloran/mjml-bundle","commit_stats":{"total_commits":131,"total_committers":15,"mean_commits":8.733333333333333,"dds":0.6106870229007634,"last_synced_commit":"afd34d561d3dc7d78ccb9b56b076d4eaf494e21e"},"previous_names":["notfloran/mjml-bundle","akollade/mjml-bundle"],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notFloran%2Fmjml-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notFloran%2Fmjml-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notFloran%2Fmjml-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notFloran%2Fmjml-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/notFloran","download_url":"https://codeload.github.com/notFloran/mjml-bundle/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254384987,"owners_count":22062422,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["email","hacktoberfest","mjml","symfony","symfony-bundle"],"created_at":"2025-02-26T23:00:25.431Z","updated_at":"2025-05-15T17:04:37.952Z","avatar_url":"https://github.com/notFloran.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MjmlBundle\n\n[![Latest Stable Version](https://poser.pugx.org/notfloran/mjml-bundle/v/stable.svg)](https://packagist.org/packages/notfloran/mjml-bundle)\n[![Latest Unstable Version](https://poser.pugx.org/notfloran/mjml-bundle/v/unstable.svg)](https://packagist.org/packages/notfloran/mjml-bundle)\n\nBundle to use [MJML](https://mjml.io/) 3 and 4 with Symfony \u003e= 3.\n\n## Installation\n\n### Applications that use Symfony Flex\n\nOpen a command console, enter your project directory and execute:\n\n```console\n$ composer require notfloran/mjml-bundle\n```\n\n### Applications that don't use Symfony Flex\n\n#### Step 1: Download the Bundle\n\nOpen a command console, enter your project directory and execute the\nfollowing command to download the latest stable version of this bundle:\n\n```console\n$ composer require notfloran/mjml-bundle\n```\n\nThis command requires you to have Composer installed globally, as explained\nin the [installation chapter](https://getcomposer.org/doc/00-intro.md)\nof the Composer documentation.\n\n#### Step 2: Enable the Bundle\n\nThen, enable the bundle by adding it to the list of registered bundles\nin the `app/AppKernel.php` file of your project:\n\n```php\n// app/AppKernel.php\n\n// ...\nclass AppKernel extends Kernel\n{\n    public function registerBundles()\n    {\n        $bundles = [\n            // ...\n            new NotFloran\\MjmlBundle\\MjmlBundle(),\n        ];\n\n        // ...\n    }\n\n    // ...\n}\n```\n\n## Renderer\n\nFor the moment only one renderer is available, the binary renderer.\n\n### Binary\n\nInstall [MJML](https://mjml.io)\n\n```bash\n$ npm install mjml\n```\n\nThen you need to update the configuration:\n\n```yaml\n# config/packages/mjml.yaml\nmjml:\n  renderer: binary # default: binary\n  options:\n    binary: '%kernel.project_dir%/node_modules/.bin/mjml' # default: mjml\n    node: '/Users/user/.nvm/versions/node/v10.16.0/bin/node' # default: null\n    minify: true # default: false\n    validation_level: skip # default: strict. See https://mjml.io/documentation/#validating-mjml\n```\n\nThe `node` option is there for those who have problems with `$PATH`, see [#35](https://github.com/notFloran/mjml-bundle/issues/35).\n\n### Custom\n\nFirst you must create a class which implements `NotFloran\\MjmlBundle\\Renderer\\RendererInterface`, then declare it as a service.\n\nAnd finally you have to change the configuration:\n\n````yaml\n# config/packages/mjml.yaml\nmjml:\n    renderer: 'service'\n    options:\n        service_id: 'App\\Mjml\\MyCustomRenderer'\n````\n\n### PHP Config\n\nIf you're using symfony 5 and want to configure this bundle with PHP files instead of YAML:\n\n```php\n// config/packages/mjml.php\n\u003c?php declare(strict_types=1);\n\nuse Symfony\\Component\\DependencyInjection\\Loader\\Configurator\\ContainerConfigurator;\n\nreturn static function (ContainerConfigurator $configurator): void\n{\n    $configurator-\u003eextension('mjml', [\n        'renderer' =\u003e 'binary',\n        'options' =\u003e [\n            'binary' =\u003e '%kernel.project_dir%/node_modules/.bin/mjml',\n            'minify' =\u003e true,\n            'validation_level' =\u003e 'skip'\n        ]\n    ]);\n};\n```\n\n### API\n\nThe bundle has no official integration with the [MJML API](https://mjml.io/api).\n\nYou can create your own integration by using [juanmiguelbesada/mjml-php](https://packagist.org/packages/juanmiguelbesada/mjml-php) and following this gist : https://gist.github.com/notFloran/ea6bab137be628f6a0c19054e08e6906.\n\n## Usage\n\n### Use \"mjml\" twig tag\n\n```twig\n{# mail/example.mjml.twig #}\n{% block email_content %}\n    {% mjml %}\n    \u003cmjml\u003e\n        \u003cmj-body\u003e\n                \u003cmj-section\u003e\n                    \u003cmj-column\u003e\n\n                        \u003cmj-image width=\"100px\" src=\"https://mjml.io/assets/img/logo-small.png\"\u003e\u003c/mj-image\u003e\n\n                        \u003cmj-divider border-color=\"#F45E43\"\u003e\u003c/mj-divider\u003e\n\n                        \u003cmj-text font-size=\"20px\" color=\"#F45E43\" font-family=\"helvetica\"\u003e\n                            Hello {{ name }} from MJML and Symfony\n                        \u003c/mj-text\u003e\n\n                    \u003c/mj-column\u003e\n                \u003c/mj-section\u003e\n        \u003c/mj-body\u003e\n    \u003c/mjml\u003e\n    {% endmjml %}\n{% endblock %}\n```\n\n```php\npublic function sendEmail(MailerInterface $mailer)\n{\n    // The MJMl body is rendered by the mjml tag in the twig file\n    $htmlBody = $this-\u003erenderView('templates/mail/example.mjml.twig', ['name' =\u003e 'Floran']);\n\n    $email = (new Email())\n        -\u003efrom('my-app@example.fr')\n        -\u003eto('me@example.fr')\n        -\u003esubject('Hello from MJML!')\n        -\u003ehtml($htmlBody);\n\n    $mailer-\u003esend($email);\n\n    // ...\n}\n```\n\n### Use \"mjml\" service\n\n```twig\n{# templates/mail/example.mjml.twig #}\n\u003cmjml\u003e\n    \u003cmj-body\u003e\n            \u003cmj-section\u003e\n                \u003cmj-column\u003e\n\n                    \u003cmj-image width=\"100px\" src=\"https://mjml.io/assets/img/logo-small.png\"\u003e\u003c/mj-image\u003e\n\n                    \u003cmj-divider border-color=\"#F45E43\"\u003e\u003c/mj-divider\u003e\n\n                    \u003cmj-text font-size=\"20px\" color=\"#F45E43\" font-family=\"helvetica\"\u003e\n                        Hello {{ name }} from MJML and Symfony\n                    \u003c/mj-text\u003e\n\n                \u003c/mj-column\u003e\n            \u003c/mj-section\u003e\n    \u003c/mj-body\u003e\n\u003c/mjml\u003e\n```\n\n```php\nuse NotFloran\\MjmlBundle\\Renderer\\RendererInterface;\n\n// ...\n\npublic function sendEmail(MailerInterface $mailer, RendererInterface $mjml)\n{\n    $mjmlBody = $this-\u003erenderView('templates/mail/example.mjml.twig', ['name' =\u003e 'Floran']);\n    $htmlBody = $mjml-\u003erender($mjmlBody);\n\n    $email = (new Email())\n        -\u003efrom('my-app@example.fr')\n        -\u003eto('me@example.fr')\n        -\u003esubject('Hello from MJML!')\n        -\u003ehtml($htmlBody);\n\n    $mailer-\u003esend($email);\n\n    // ...\n}\n```\n\n## SwiftMailer integration\n\n*❗ This integration is deprecated and will be removed in the next major version.*\n\nDeclare the following service:\n\n```yaml\nNotFloran\\MjmlBundle\\SwiftMailer\\MjmlPlugin:\n    tags: [swiftmailer.default.plugin]\n```\n\nCreate a SwiftMailer message with a MJML body (without `{% mjml %}`) and with `text/mjml` as content-type:\n\n```php\n$message = (new \\Swift_Message('Hello Email'))\n    -\u003esetFrom('send@example.com')\n    -\u003esetTo('recipient@example.com')\n    -\u003esetBody(\n        $this-\u003erenderView('mail/example.mjml.twig'),\n        'text/mjml'\n    );\n\n$mailer-\u003esend($message);\n```\n\nThe plugin will automatically render the MJML body and replace the body with the rendered HTML.\n\nIn the case where a spool is used: the MJML content is save in the spool and render when the spool is flushed.\n\n## License\n\n[MjmlBundle](https://github.com/notFloran/mjml-bundle) is licensed under the [MIT license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotfloran%2Fmjml-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnotfloran%2Fmjml-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotfloran%2Fmjml-bundle/lists"}