Download the PHP package escolalms/templates-email without Composer
On this page you can find all versions of the php package escolalms/templates-email. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download escolalms/templates-email
More information about escolalms/templates-email
Files in escolalms/templates-email
Package templates-email
Short Description Escola Headless LMS Templates for Emails
License MIT
Informations about the package templates-email
Templates-Email
Package for email notifications with editable templates (for important user-related events)
Purpose
This package allows you to create email notifications for events emitted in Laravel app.
Each notification is created as a class describing available variables that can be used in Template (which will be created in database and editable through admin panel). This class must be registered using Template facade from Template package, where you specify which Event it is associated with and which Channel it is sent through (e.g. Email channel when defined in this package).
Installing
composer require escolalms/templates-email
php artisan db:migrate
php artisan db:seed --class="EscolaLms\TemplatesEmail\Database\Seeders\TemplatesEmailSeeder"
Dependencies
Usage
Defining Templates
- Create event which triggers sending email using specified template. This event must implement method getUser() returning User model from LMS Core package.
- Create Class defining template variables, which you will use in email notification,
- Associate your class describing template variables with event and channel through which notifications should be sent. Use
EscolaLms\Templates\Facades\Template::register(Event class, EscolaLms\TemplatesEmail\Core\EmailChannel::class, Variable class);
- Register template in db for admin panel or used
/api/admin/templates
, better described in Template package
Mjml (pre)rendering
- Emails are written using MJML, which then is prerendered into HTML when saving a Template (so that sending an email does not call renderer for each message).
- To render MJML you need to either:
- install
mjml
npm package and configure path to executable binary in this package configbinary_path
key - register to MJML API and configure api id & secret in this package config file
- install
Tests
Run ./vendor/bin/phpunit --filter 'EscolaLms\\TemplatesEmail\\Tests'
to run tests. See tests folder as it contains a basic implementation of Variable (or Template description) class with minimal customisation - a quite good starting point for creating your own.
Permissions
No Permissions defined for this package.
All versions of templates-email with dependencies
escolalms/core Version ^1.2.2
escolalms/templates Version ^0.2.1
ezyang/htmlpurifier Version ^4.13
laravel/framework Version >=8.0
qferr/mjml-php Version ^2