Download the PHP package ronasit/laravel-chat without Composer
On this page you can find all versions of the php package ronasit/laravel-chat. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-chat
Laravel Chat Plugin
Table of Contents
- Introduction
- Installation
- Integration with LaravelSwagger
- API Endpoints
- Conversations
- Messages
- Broadcast Events
- Channel Authorization
- Events
- Contributing
- License
Introduction
This plugin adds the ability for users to work with chat functionalities in a Laravel application.
Installation
-
Install the package using the following command:
-
Publish the package configuration:
- If you use non default
App\Models\Usermodel - updatechat.classes.user_modelconfig.
Integration with LaravelSwagger
This package includes an OpenAPI documentation file. To include it in your project's documentation, you need to register it in the auto-doc.additional_paths config:
vendor/ronasit/laravel-chat/documentation.json
API Endpoints
All routes are registered by default, you can change the route registration by calling Route::chat() in your routes
file (e.g. routes/api.php):
- feel free to call
Route::chat()helper inside any route wrappers likegroup,prefix, etc. to wrap package routes; In this case the package's default routes are not registered at all. A request to a disabled endpoint returns404, or405 Method Not Allowedwhen the same URI is still served by another HTTP method; Route::chat()must be called from a routes file that is loaded during the application boot (e.g.routes/api.php), so that it runs before the package registers its default routes;- calling
Route::chat()without args will add all package routes inside the calling helper place; - calling
Route::chat()withChatRouteActionEnumcases as arguments will register only the specified routes — all others are automatically disabled:
All endpoints are using the current auth user context, so it critical to always wrap them into the auth middleware.
Conversations
| Method | URL | Description |
|---|---|---|
GET |
/conversations |
List all conversations the authenticated user is a member of. |
GET |
/conversations/{id} |
Retrieve a single conversation by its ID. |
DELETE |
/conversations/{id} |
Delete a conversation. |
GET |
/users/{userId}/conversation |
Get the private conversation between the authenticated user and the specified user. |
Messages
| Method | URL | Description |
|---|---|---|
GET |
/messages |
List of messages related to the current user's conversations. |
POST |
/messages |
Create a new message. |
POST |
/messages/{id}/read-to |
Mark all messages in the target message's conversation as read up to the specified message ID. |
POST |
/messages/{id}/pin |
Pin a message to its conversation. |
POST |
/messages/{id}/unpin |
Unpin a message from its conversation. |
Broadcast Events
The package uses Laravel's broadcasting system to notify conversation members in real time. All events are delivered over private channels named chat.{userId}, where {userId} is the ID of the recipient.
Channel Authorization
A user may listen on only his own private channel chat.{userId}. The channel is authorized when the authenticated user's ID matches {userId}.
Events
conversation.created
Sent to all conversation members except the creator when a new conversation is created.
This event is triggered when:
- A new group conversation is created.
- A private conversation is created implicitly (e.g., when a user sends the first message to another user via
recipient_id).
Payload:
conversation.updated
Sent to all conversation members when a conversation is modified.
This event is triggered when:
- A conversation's properties (e.g., title, cover) are updated.
- A new message is created (the conversation's
last_updated_atis updated as a side effect). - A message is pinned or unpinned in the conversation.
Payload:
conversation.deleted
Sent to all conversation members except the user who deleted it when a conversation is removed.
This event is triggered when:
- A conversation is deleted via
DELETE /conversations/{id}.
Payload:
message.created
Sent to all conversation members except the sender when a new message is posted.
This event is triggered when:
- A message is created via
POST /messages.
Payload:
message.updated
Sent to all conversation members when the read status of one or more messages changes.
This event is triggered when:
- A user marks messages as read via
POST /messages/{id}/read-to.
Payload:
Contributing
Thank you for considering contributing to the Laravel Chat plugin! The contribution guide can be found in the Contributing guide.
License
Laravel Chat plugin is open-sourced software licensed under the MIT license.
All versions of laravel-chat with dependencies
laravel/framework Version >=12
ronasit/laravel-helpers Version >=3.7.2
ronasit/laravel-media Version >=0.2