ritechoice23 / laravel-chat-engine
A UI-agnostic, transport-agnostic, polymorphic chat engine for Laravel with message versioning, reactions, bookmarks, and delivery tracking.
Fund package maintenance!
ritechoice23
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/ritechoice23/laravel-chat-engine
Requires
- php: ^8.2
- illuminate/contracts: ^11.0||^12.0
- ritechoice23/laravel-reactions: ^1.0
- ritechoice23/laravel-saveable: ^1.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.0.0||^9.0.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
This package is auto-updated.
Last update: 2026-01-06 15:08:43 UTC
README
A UI-agnostic, transport-agnostic, polymorphic chat engine for Laravel.
Features
- Polymorphic Actors - Users, Teams, Bots, or any model can chat
- Thread Types - Direct, Group, Channel, Broadcast, Custom
- Rich Messages - Text, Image, Video, Audio, File, Location, Contact, Custom
- Attachments - Multi-file uploads, view-once media, direct request uploads
- Security - Thread locks, PIN protection, E2E verification codes
- Reactions - Emoji reactions via
laravel-reactionsintegration - Bookmarks - Save/bookmark messages via
laravel-saveableintegration - Delivery Tracking - Delivered and read receipts
- Edit History - Immutable message versions (configurable)
- Soft/Hard Delete - Configurable deletion modes
- Authorization - Built-in policies for threads and messages
- Pipelines - Message processing (sanitize, mentions, URLs, profanity)
- Events - Domain events for all actions
- API Resources - Ready-to-use JSON transformations
Requirements
- PHP 8.2+
- Laravel 11.x or 12.x
Installation
composer require ritechoice23/laravel-chat-engine
Publish the config file:
php artisan vendor:publish --tag="chat-engine-config"
Run migrations:
php artisan migrate
Quick Start
Add the trait to your User model:
use Ritechoice23\ChatEngine\Traits\CanChat; class User extends Authenticatable { use CanChat; }
Start chatting:
use Ritechoice23\ChatEngine\Facades\Chat; // Create a thread $thread = Chat::thread()->between($userA, $userB)->create(); // Send a message $message = Chat::message() ->from($userA) ->to($thread) ->text('Hello!') ->send(); // React to message $userB->react($message, '❤️'); // Bookmark message $userB->saveItem($message); // Mark as read $message->markAsReadBy($userB);
File Uploads
Upload files directly from Laravel requests:
// Single file Chat::message() ->from($request->user()) ->to($thread) ->text('Check this out!') ->attachUpload($request->file('photo')) ->send(); // Multiple files Chat::message() ->from($request->user()) ->to($thread) ->attachUploads($request->file('attachments')) ->send(); // View-once (self-destructing) Chat::message() ->from($request->user()) ->to($thread) ->attachUploadViewOnce($request->file('secret')) ->send();
Message Types
// Text Chat::message()->from($user)->to($thread)->text('Hello')->send(); // Image Chat::message()->from($user)->to($thread) ->image('https://...', 'Caption')->send(); // Video Chat::message()->from($user)->to($thread) ->video('https://...', 'thumb.jpg', 120)->send(); // File Chat::message()->from($user)->to($thread) ->file('https://...', 'doc.pdf', 'application/pdf')->send(); // Location Chat::message()->from($user)->to($thread) ->location(40.7128, -74.0060, 'NYC')->send(); // Contact Chat::message()->from($user)->to($thread) ->contact('John Doe', '+1234567890', 'john@example.com')->send();
Thread Types
// Direct (1-on-1, automatically deduplicated) Chat::thread()->between($userA, $userB)->create(); // Group Chat::thread()->group('Team Chat')->participants([$u1, $u2, $u3])->create(); // Channel Chat::thread()->channel('announcements')->create(); // Broadcast Chat::thread()->broadcast('System Updates')->create();
Documentation
See /docs for complete documentation:
| Getting Started | Core Features | System | Advanced |
|---|---|---|---|
| Installation | Threads | Events | Encryption |
| Configuration | Messages | Policies | Retention |
| Attachments | Pipelines | Scaling | |
| Security | Presence | Customization | |
| Delivery | API Resources | ||
| Reactions | |||
| Bookmarks |
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
If you discover a security vulnerability, please send an email to daramolatunde23@gmail.com. All security vulnerabilities will be promptly addressed.
Credits
License
The MIT License (MIT). Please see License File for more information.