Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Mail Template Bundle Laravel Package

schvoy/mail-template-bundle

A PHP package for managing and rendering mail templates. Keep transactional email templates organized, edit content without touching code, and render messages with dynamic variables. A lightweight way to centralize mail layouts and reuse them across your application.

View on GitHub
Deep Wiki
Context7

Getting Started

  • Install via Composer: composer require schvoy/mail-template-bundle. Note this is a Symfony bundle built on Doctrine, not a native Laravel package. In a Laravel project you’ll need Doctrine (e.g., laravel-doctrine/orm) and Symfony components to use it directly.
  • Start with the README.md and the MailTemplateEntityInterface. In v1.0.1 you must implement the entity such that at least one of content or templatePath is set (enforced by the package).
  • First use case: create a Doctrine entity implementing MailTemplateEntityInterface (with content or templatePath), persist it, then use the bundle’s rendering service to produce the final email body (likely Twig-based) and send via your mailer.

Implementation Patterns

  • Entity-driven templates: define your Doctrine entity, map fields (content, templatePath, subject, etc.), and use the bundle’s repository/services to load and render templates by identifier.
  • Rendering workflow: fetch template → inject placeholders/variables → render (Twig) → pass to MailerInterface. For Laravel, consider wrapping this in a job or service that bridges to Laravel’s Mail facade.
  • Admin CRUD: build a back-office to manage templates; validate that either content or templatePath is present before persisting (mirroring the v1.0.1 rule).
  • Integration tips: If you’re mostly in Laravel, evaluate whether you can achieve the same with Laravel Mailables + Blade + database-driven views. Use this bundle only if you already run Doctrine or need its specific template resolution logic. For hybrid apps, isolate the bundle in a Symfony/Doctrine service layer.

Gotchas and Tips

  • v1.0.1 behavior change: the package now enforces that exactly one of content or templatePath is mandatory on MailTemplateEntityInterface. Existing templates without either will fail validation—audit your data before upgrading.
  • Framework mismatch: this is a Symfony bundle; in Laravel you’ll need to wire Doctrine, register bundle services manually (or via a bridge), and handle Twig separately. Plan for extra glue code.
  • Debugging: when a template fails to render, check which of content/templatePath is set, verify Twig template paths, and confirm the entity implements the interface correctly. The v1.0.1 rule is enforced; look for validation exceptions or constraint violations.
  • Extension points: implement MailTemplateEntityInterface on your own entity, override the rendering service, and use the package’s events/hooks (if exposed) for placeholder resolution. Keep your entity’s validation aligned with the mandatory field rule to avoid runtime surprises.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
mydnic/volet-feature-board-filament-plugin
wmde/email-address
refinery29/test-util
dees040/laravel-api-responses
teamzac/geocoder
ideatica/config-writer
keaton-php/pipe-dream
jacksonwebservices/laravel-user-suite
maksimru/conditional-laravel-debugbar
gismatul/nova-support-chat
gismatul/laravel-support-chat
networkrailbusinesssystems/oracle-api
alphabalex/messaging-made-easy
rawphp/warp
shootkiran/merobug
narakode/fineauth
numencode/wn-syncops-plugin
ibnnajjaar/mib-global-pay
refinery29/php-cs-fixer-config
parsnick/steak