NewWe open-sourced 50+ Laravel packages
Custom AI apps, agents and automation — Roundly ConsultingRoundly
All packages

Require the package. The service provider and the Messages facade alias are auto-discovered — no manual registration:

composer require roundly-consulting/messages-for-laravel

Composer also pulls in the three sibling packages Messages is built on — enums-for-laravel, media-library-for-laravel and package-toolkit-for-laravel. There is nothing to install or configure for them separately.

Key type first

If your participating models (usually User) are keyed by uuid or ulid, set that before you migrate — it is baked into the schema (see Key types):

MESSAGES_KEY_TYPE=uuid   # bigint (default) | uuid | ulid — your models' primary key type

Publish-only migrations

Migrations are not loaded automatically — a bare php artisan migrate creates nothing until you publish them. Messages stores attachments through media-library-for-laravel, installed with it, whose media table is publish-only too — publish both, then migrate:

php artisan vendor:publish --tag="media-migrations"
php artisan vendor:publish --tag="messages-migrations"
php artisan migrate

Skip media-migrations and the first send fails, because every send looks up the message’s attachments, whether or not it has any:

no such table: media

The eleven messages migrations land in database/migrations under timestamped filenames that preserve the order the tables depend on each other in, so they interleave correctly with your own. They create messaging_threads, messaging_participants and messaging_messages — all with soft deletes and a configurable key type.

Optional publishes

php artisan vendor:publish --tag="messages-config"
php artisan vendor:publish --tag="messages-translations"
php artisan vendor:publish --tag="messages-resources"
php artisan vendor:publish --tag="messages-notifications"
  • messages-config — config/messages.php; every key has an env-backed default, so this is only needed to override.
  • messages-translations — the system-message, preview and exception strings.
  • messages-resources — editable copies of the JSON API resources in App\Http\Resources\Messages (app/Http/Resources/Messages).
  • messages-notifications — an editable copy of the new-message notification in App\Notifications\Messages (app/Notifications/Messages).

Next steps

  • Implement ParticipatesInMessaging and add the HasMessaging trait to every model that sends or takes part.
  • Open a DM with Messages::direct() or a group with Messages::start() — or the trait’s conversationWith() and startConversationWith().
  • Optionally turn on broadcasting, notifications and system messages via env.

Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

More ways to support, including crypto

By donating, you agree to our donation terms.

Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.