Download the PHP package charlielangridge/laravel-mail-previewer without Composer
On this page you can find all versions of the php package charlielangridge/laravel-mail-previewer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download charlielangridge/laravel-mail-previewer
More information about charlielangridge/laravel-mail-previewer
Files in charlielangridge/laravel-mail-previewer
Package laravel-mail-previewer
Short Description Laravel Mail Previewer - allows you to preview mailables and notifications with data
License MIT
Homepage https://github.com/charlielangridge/laravel-mail-previewer
Informations about the package laravel-mail-previewer
Laravel Mail Previewer
Discover mailables and notifications in a Laravel app, inspect required inputs, and render preview HTML safely.
This package is designed for internal preview tooling and admin UIs.
Features
- Discover all app mailables and notifications.
- Return structured metadata:
- short
name - full
class subject(including dynamic placeholder parsing)input_requirements
- short
- Resolve required constructor input for a selected class.
- For model-typed inputs, return up to 100 selectable DB options.
- Render HTML previews for mailables and notifications.
- Never sends email when rendering previews.
Requirements
- PHP
^8.4 - PHP
^8.3 - Laravel
^11.0 || ^12.0
Installation
The package auto-registers via Laravel package discovery.
Quick Start
API
LaravelMailPreviewer::discover(): array
Returns both mailables and notifications:
Subject extraction rules:
- Uses class-level default
subjectwhen available. - Parses common subject definitions from class source:
Envelope(subject: ...)->subject(...)
- Resolves local variables where possible:
$subject = 'Test'; ->subject($subject)becomesTest
- External/runtime references are converted to placeholders:
'Hello '.$this->user->namebecomesHello **user->name**
LaravelMailPreviewer::inputRequirements(string $className): array
Returns required constructor parameters for a mailable/notification.
If parameter type is an Eloquent model, includes options from DB (limit 100):
Notes:
- Non-model parameters do not include
options. - Unsupported classes return an empty array.
LaravelMailPreviewer::inputTypeHintingIssues(): array
Returns mailables/notifications where required constructor inputs are not properly type-hinted
(missing type hint or resolved as mixed), so you can work through and fix them.
Suggestion strategy:
- Uses default parameter value type when present.
- Attempts to map parameter names to app model classes.
- Applies name heuristics (
...Id=>int,is...=>bool,token/email/name/...=>string). - Falls back to
string.
LaravelMailPreviewer::renderHtml(string $className, array $parameters = [], mixed $notifiable = null): ?string
Renders HTML preview for a mailable or notification using Laravel's rendering pipeline.
For model-typed constructor inputs, scalar values are treated as primary keys and resolved via findOrFail.
$notifiable is optional for notifications. If omitted, an internal anonymous notifiable is used.
Important:
- This method does not call send/notify pathways.
- It is for preview rendering only.
Tinker Examples
Testing
Changelog
Please see CHANGELOG for details.
License
MIT. See LICENSE.md.
All versions of laravel-mail-previewer with dependencies
illuminate/contracts Version ^11.0||^12.0||^13.0
spatie/laravel-package-tools Version ^1.16