Hosmel Quintana
Laravel Audit LogsLaravel Message Preview
Introduction
Installation
Configuration
Basic usage
Previewing Messages
Sample Data
Notifications
Checking Messages
View on GitHub

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:

bash
php artisan message-preview:check

Each 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:

bash
php artisan message-preview:check --locale=en --locale=es

Use --all-locales for the locales found in the application's translation directories and JSON files, plus its configured locale and fallback locale:

bash
php artisan message-preview:check --all-locales --strict

Repeated 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:

yaml
- name: Check messages
  run: php artisan message-preview:check --all-locales --strict
  env:
    APP_ENV: testing

The 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:

bash
php artisan message-preview:check --all-locales --strict --json

The report has one entry per render, the discovery errors, and a summary:

json
{
    "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.

Notifications