PHPackages                             metafroliclabs/laravel-chat - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. metafroliclabs/laravel-chat

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

metafroliclabs/laravel-chat
===========================

A powerful and customizable chat system built for Laravel applications. This package supports private and group chats, media sharing, chat settings, user roles, activity messages, and more.

v1.4.0(11mo ago)038MITPHPPHP ^8.1

Since Jun 6Pushed 11mo agoCompare

[ Source](https://github.com/metafroliclabs/laravel-chat)[ Packagist](https://packagist.org/packages/metafroliclabs/laravel-chat)[ RSS](/packages/metafroliclabs-laravel-chat/feed)WikiDiscussions master Synced today

READMEChangelog (10)DependenciesVersions (15)Used By (0)

[![Laravel Logo](https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg)](https://laravel.com)

Laravel Chat Package
====================

[](#laravel-chat-package)

A powerful and customizable chat system built for Laravel applications. This package supports private and group chats, media sharing, chat settings, user roles, activity messages, and more.

🚀 Features
----------

[](#-features)

- Dual-mode (standard/universal) design.
- Private &amp; Group Chat Support.
- Message types: message, activity
- User roles: admin, user
- Group settings (all permissions control)
- Message read/unread tracking
- Activity messages on: group creation, joins, leaves, settings changes
- Media upload support
- Configurable user info: name, avatar
- Extendable &amp; clean architecture (Service-based)

📦 Installation
--------------

[](#-installation)

```
composer require metafroliclabs/laravel-chat
```

```
php artisan larachat:install
```

Or, manually publish configuration file:

```
php artisan vendor:publish --tag=chat-config
```

Run migrations:

```
php artisan migrate
```

Make sure storage is linked:

```
php artisan storage:link
```

⚙️ Configuration
----------------

[](#️-configuration)

Customize settings in `config/chat.php`:

#### 1. Chat type:

[](#1-chat-type)

You can switch between `standard` (private/group chat) and `universal` (global chat):

```
'type' => 'standard',
```

Also in universal type, you can enable/disable modules:

```
'features' => [
    'reactions' => true,
    'views' => false
],
```

#### 2. Pagination:

[](#2-pagination)

You can also enable or disable pagination:

```
'pagination' => true,
```

#### 3. Activity Messages

[](#3-activity-messages)

Automatically generated for:

- Group creation
- User added/removed
- Group settings updated
- User left the chat

You can disable all activity messages globally:

```
'message' => [
    'enable_activity' =>  false,
]
```

#### 4. User Model Configuration

[](#4-user-model-configuration)

Define how user information (name and avatar) is retrieved:

```
'user' => [
    'model' => \App\Models\User::class,         // Default user model
    'name_cols' => ['first_name', 'last_name'], // Columns to build full name
    'image_col' => 'avatar',                    // Column for profile picture
    'enable_image_url' => true,                 // If true, image will be URL
]
```

#### 5. Rate Limiting

[](#5-rate-limiting)

You can control how many chats a user can create and how many messages they can send per minute. These limits help prevent spam and abuse.

```
'rate_limits' => [
    'chat_creation_per_minute' => 20, // Max 20 chats per user per minute
    'messages_per_minute' => 40      // Max 40 messages per user per minute
],
```

- Limits are enforced per authenticated user (or IP if unauthenticated).
- You can adjust these values to suit your application's needs.

📡 Events in Laravel Chat
------------------------

[](#-events-in-laravel-chat)

Laravel Chat dispatches events to help you hook into the system and extend functionality such as notifications, logging, analytics, and more.

### 🔥 Available Events

[](#-available-events)

#### `Metafroliclabs\LaravelChat\Events\MessageSent`

[](#metafroliclabslaravelchateventsmessagesent)

Dispatched when a message is successfully sent or forwarded in a chat.

#### Event Data:

[](#event-data)

```
public MessageSent(Chat $chat, array $messages, User $sender, array $receiver)
```

### ⚙️ How to Use

[](#️-how-to-use)

#### Step 1: Create a Listener

[](#step-1-create-a-listener)

```
php artisan make:listener HandleMessageSent
```

#### Step 2: Handle the Event

[](#step-2-handle-the-event)

```
namespace App\Listeners;

use Metafroliclabs\LaravelChat\Events\MessageSent;
use Illuminate\Contracts\Queue\ShouldQueue;

class HandleMessageSent implements ShouldQueue
{
    public function handle(MessageSent $event)
    {
        $chat = $event->chat;
        $messages = $event->messages;
        $sender = $event->sender;
        $receivers = $event->receivers;

        // Example: Send push notifications or log activity
    }
}
```

### 🔧 Register the Listener

[](#-register-the-listener)

In your `app/Providers/EventServiceProvider.php`:

```
protected $listen = [
    Metafroliclabs\LaravelChat\Events\MessageSent::class => [
        App\Listeners\HandleMessageSent::class,
    ],
];
```

Then run:

```
php artisan event:cache
```

📡 Custom User Filters
---------------------

[](#-custom-user-filters)

You can customize how chat lists are filtered based on user attributes (like gender, role, etc.).

### ⚙️ How to Use

[](#️-how-to-use-1)

#### Step 1: Create a Filter Class

[](#step-1-create-a-filter-class)

Create a custom filter class in your project and extend the base filter class provided by Laravel Chat:

```
namespace App\Filters;

use Metafroliclabs\LaravelChat\Filters\BaseFilter;

class ChatUserFilter extends BaseFilter
{
    protected function applyUserFilters($query): void
    {
        // Example: Filter users by gender
        if ($this->request->filled('gender')) {
            $query->where('gender', $this->request->gender);
        }

        // You can add more filters here...
    }

    protected function hasActiveUserFilters(): bool
    {
        return $this->request->filled('gender');
    }
}
```

#### Step 2: Register Your Filter Class

[](#step-2-register-your-filter-class)

In your `config/chat.php` file, register your custom filter class:

```
'filter' => \App\Filters\ChatUserFilter::class,
```

🧠 Usage
-------

[](#-usage)

#### 📚 API Endpoints

[](#-api-endpoints)

All routes are prefixed by the config value `chat.prefix` (default: chat) and use the `chat.middleware` middleware group.

*Middleware:* `auth:sanctum` is required.

#### 🔍 Chat List &amp; Info

[](#-chat-list--info)

MethodEndpointDescriptionGET`/all/list`Get all chats for the userGET`/unread/list`Get all unread chatsGET`/unread/count`Get unread chat count#### 🛠️ Chat Management

[](#️-chat-management)

MethodEndpointDescriptionPOST`/create`Create private chatPOST`/create/group`Create group chatPOST`/{id}/update`Update chat name/image/settingsPOST`/{id}/delete`Delete a chatPOST`/{id}/leave`Leave group chatPOST`/{id}/mute`Mute/unmute chatGET`/{id}`Get chat detail#### 👥 User Management

[](#-user-management)

MethodEndpointDescriptionGET`/{id}/users`Get all users in the chatPOST`/{id}/users/add`Add users to a groupPOST`/{id}/users/remove`Remove usersPOST`/{id}/users/{uid}/admin`Promote/demote user to/from admin#### 💬 Messaging

[](#-messaging)

MethodEndpointDescriptionGET`/{id}/messages`Get all messages in a chatPOST`/{id}/messages`Send a new messagePOST`/{id}/messages/forward`Forward messagesPOST`/{id}/messages/{mid}/update`Update a messagePOST`/{id}/messages/{mid}/delete`Delete a message#### 💖 Reactions &amp; Views

[](#-reactions--views)

MethodEndpointDescriptionGET`/{id}/messages/{mid}/likes`Get users who liked a messagePOST`/{id}/messages/{mid}/likes`Like/unlike a messageGET`/{id}/messages/{mid}/views`Get users who viewed a messagePOST`/{id}/messages/{mid}/views`Mark message as viewed#### ⚡ Rate Limiting

[](#-rate-limiting)

Some endpoints are rate limited to prevent abuse:

- **Chat Creation** (`/create`, `/create/group`): Limited to `chat_creation_per_minute` (default: 20) per user per minute.
- **Message Sending** (`/{id}/messages`, `/{id}/messages/forward`): Limited to `messages_per_minute` (default: 40) per user per minute.

If a user exceeds these limits, a `429 Too Many Requests` response will be returned by the API.

📄 License
---------

[](#-license)

This project is licensed under the MIT License.

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance52

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~4 days

Recently: every ~10 days

Total

13

Last Release

337d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/196910403?v=4)[MFL](/maintainers/metafroliclabs)[@metafroliclabs](https://github.com/metafroliclabs)

---

Top Contributors

[![wasifrazasalsoft5987](https://avatars.githubusercontent.com/u/126851459?v=4)](https://github.com/wasifrazasalsoft5987 "wasifrazasalsoft5987 (62 commits)")

---

Tags

phplaravelchatMessengerconversations

### Embed Badge

![Health badge](/badges/metafroliclabs-laravel-chat/health.svg)

```
[![Health](https://phpackages.com/badges/metafroliclabs-laravel-chat/health.svg)](https://phpackages.com/packages/metafroliclabs-laravel-chat)
```

###  Alternatives

[munafio/chatify

A package for Laravel PHP Framework to add a complete real-time chat system.

2.4k479.0k2](/packages/munafio-chatify)[nahid/talk

Talk is a Laravel based realtime messaging, chatting and conversation system. It helps to develop users messaging, chatting and conversations in easy way.

1.6k59.0k4](/packages/nahid-talk)[lexxyungcarter/chatmessenger

Simple one-to-one/group chat messaging tool for Laravel 5, 6, 7, 8, 9 &amp; 10 with Pusher Integration

10725.7k](/packages/lexxyungcarter-chatmessenger)[syntaxlexx/chatmessenger

Simple one-to-one/group chat messaging tool for Laravel 5, 6, 7, 8, 9 &amp; 10 with Pusher Integration

10511.5k](/packages/syntaxlexx-chatmessenger)[baklysystems/laravel-chat-messenger

Laravel chat package

121.8k](/packages/baklysystems-laravel-chat-messenger)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
