Checking Messages
Render every message and variant from the command line.
Render every message
Run the check command to render every discovered message and each of its variants:
php artisan message-preview:checkEach render uses the same mail pipeline and database rollback as the browser preview. Messages render in their own locale by default, including a notification's preferred notifiable locale.
The command prints one status line per message, variant, and locale, followed by a summary. Exceptions, invalid previewConfig() methods, and discovery errors make it exit with code 1. It continues checking the remaining messages after a failure. Missing translations and placeholders a translation kept without a value are warnings; add --strict to make warnings fail too. Otherwise it exits with code 0.
Choose locales
Repeat --locale to render every message and variant in the given locales:
php artisan message-preview:check --locale=en --locale=esUse --all-locales for the locales found in the application's translation directories and JSON files, plus its configured locale and fallback locale:
php artisan message-preview:check --all-locales --strictRepeated locales are checked once. When combined with --all-locales, additional --locale values are included too.
Run in CI
After installing dependencies and preparing the application's test database, add a step:
- name: Check messages
run: php artisan message-preview:check --all-locales --strict
env:
APP_ENV: testingThe command can run outside the local environment.
JSON output
Use --json to print only a JSON document to standard output. It keeps the same exit codes and works with the locale and strict options:
php artisan message-preview:check --all-locales --strict --jsonThe report has one entry per render, the discovery errors, and a summary:
{
"discovery_errors": [],
"renders": [
{
"class_name": "App\\Mail\\OrderShipped",
"error": null,
"key": "App.Mail.OrderShipped",
"locale": "es",
"missing_replacements": [
{"key": "orders.greeting", "placeholder": ":name"}
],
"missing_translations": ["orders.subject"],
"status": "warning",
"variant": "default"
}
],
"summary": {
"discovery_errors": 0,
"failed": 0,
"passed": 0,
"total": 1,
"warnings": 1
}
}status is passed, warning, or failed. missing_translations is a sorted list of unique keys and is empty when none are reported. missing_replacements lists the placeholders a translation kept because no value was passed for them, each with its translation key and placeholder, sorted by key. A failed render has an error object with exception, file, line, and message; otherwise error is null. File and line can be null when unavailable. Discovery errors are strings, reported separately from render failures.
locale is the actual rendered locale. On failure, it is the requested locale, or null when using the message's own locale. Failed renders have empty missing_translations and missing_replacements lists because no rendered message is available. Strict mode keeps the warning status and changes only the exit code.