Search by

firstlightui / chat-server

wojt-janowski

Laravel package for Firstlight Chat backends: conversations, ordered messages, read cursors, unread counts, attachments, broadcasting and push through your own notifier.

Package info

github.com/firstlightui/chat-server

Homepage

pkg:composer/firstlightui/chat-server

Statistics

Installs: 6

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0-beta1 2026-11-28 09:36 UTC

This package is auto-updated.

Last update: 2026-11-28 20:13:29 UTC


README

A Laravel package that implements the server side of the Firstlight Chat protocol: conversations, messages numbered per conversation, delivered and read cursors, unread counts, private attachments, broadcasts and push.

composer require "firstlightui/chat-server:^1.0@beta"
php artisan migrate

Routes live under /api/chat behind auth:sanctum; change both in config/chat.php (php artisan vendor:publish --tag=chat-config).

Conversations

Your app decides who can talk to whom, so conversations are created in your own code:

use FirstlightUI\ChatServer\Facades\Chat;

$direct = Chat::direct($jo, $sam);            // one per pair
$group = Chat::group('Dinner', [$jo, $sam]);  // the first member owns it
Chat::add($group, $alex);
Chat::remove($group, $sam);

Push

After a message is stored, the package calls FirstlightUI\ChatServer\Contracts\ChatNotifier with every other member and their unread total. The default sends NewChatMessage through the channels in chat.notifications.channels; extend it with your channel's method, such as toApn() or toFcm(), starting from apns() and fcm(), which already hold the protocol's thread, tag, badge and payload keys. Or bind your own notifier.

Broadcasting

Events go to private-chat.user.{id} and carry IDs only. The package registers the channel authorisation; enable Laravel broadcasting (Reverb or Pusher) in your app.

License

MIT. See LICENSE.