PHPackages                             devsfort/laravel-pigeon-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. devsfort/laravel-pigeon-chat

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

devsfort/laravel-pigeon-chat
============================

A Laravel package that allows you to add a complete user messaging system into your new/existing Laravel application with only a few easy steps..

v2.1.7(8mo ago)1031MITPHPPHP &gt;=7.4

Since Jun 12Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/hahmad748/laravel-pigeon-chat)[ Packagist](https://packagist.org/packages/devsfort/laravel-pigeon-chat)[ RSS](/packages/devsfort-laravel-pigeon-chat/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (5)Used By (0)

[![devsfort logo](/src/assets/imgs/devsfort.png)](/src/assets/imgs/devsfort.png)

\# Laravel Pigeon Chat [![Latest Version on Packagist](https://camo.githubusercontent.com/39fd1efb99154c99a88a9768244681a926749c1169977bcdadf5e474e7d8b2bc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64657673666f72742f6c61726176656c2d706967656f6e2d636861742e737667)](https://packagist.org/packages/devsfort/laravel-pigeon-chat)[![Total Downloads](https://camo.githubusercontent.com/2514b6f299802c1cf41f733a3e0d6ef577a0a275a8729a58810ed4db78ed4984/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64657673666f72742f6c61726176656c2d706967656f6e2d636861742e737667)](https://packagist.org/packages/devsfort/laravel-pigeon-chat)[![License](https://camo.githubusercontent.com/1e8a455bdb0a665322ada1e31b508eae6bddf268b95d5b2bffa082c5497fcd15/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f64657673666f72742f6c61726176656c2d706967656f6e2d636861742e737667)](https://packagist.org/packages/devsfort/laravel-pigeon-chat)

A **highly customizable** Laravel package that provides a complete real-time chat system with individual messaging, group chat, and extensive customization capabilities. Built with modern technologies including Socket.IO, Redis, and Laravel's broadcasting system.

📑 **Table of Contents**
-----------------------

[](#-table-of-contents)

- [🚀 Features](#-features)
- [📋 Requirements](#-requirements)
- [🛠 Installation](#-installation)
- [⚙️ Configuration](#%EF%B8%8F-configuration)
- [🎯 Quick Start](#-quick-start)
- [🔧 Customization](#-customization)
- [🏗 Architecture](#-architecture)
- [📊 Database Schema](#-database-schema)
- [🚀 Real-time Features](#-real-time-features)
- [🔒 Security Features](#-security-features)
- [📈 Performance &amp; Scalability](#-performance--scalability)
- [🧪 Testing](#-testing)
- [🔧 Troubleshooting](#-troubleshooting)
- [📚 Documentation](#-documentation)
- [🤝 Contributing](#-contributing)
- [📄 License](#-license)
- [👨‍💻 Author](#%EF%B8%8F-author)
- [🙏 Acknowledgments](#-acknowledgments)
- [🔄 Changelog](#-changelog)
- [📞 Support](#-support)

🚀 **Features**
--------------

[](#-features)

### **Core Chat Functionality**

[](#core-chat-functionality)

- ✅ **Individual User Chat** - One-to-one messaging between users
- ✅ **Group Chat** - Multi-user group conversations with admin controls
- ✅ **Real-time Messaging** - Instant message delivery using Socket.IO
- ✅ **File Attachments** - Support for images, documents, and other files
- ✅ **Message Status** - Read receipts and delivery confirmations
- ✅ **Typing Indicators** - Real-time typing notifications
- ✅ **User Status** - Online/offline status tracking
- ✅ **Search &amp; Favorites** - Message search and favorite conversations
- ✅ **Dark/Light Mode** - User preference themes
- ✅ **Responsive Design** - Mobile-friendly chat interface

### **Advanced Features**

[](#advanced-features)

- ✅ **Channel-Based Broadcasting** - Separate channels for user and group chats
- ✅ **Room Management** - Efficient Socket.IO room handling
- ✅ **Permission System** - Granular control over user actions
- ✅ **Content Moderation** - Customizable message validation
- ✅ **Caching System** - Configurable caching for performance
- ✅ **API Support** - RESTful API endpoints with rate limiting
- ✅ **Notification System** - Multi-channel notifications
- ✅ **Database Optimization** - Efficient queries and relationships

### **Customization &amp; Extensibility**

[](#customization--extensibility)

- ✅ **Complete Override System** - Override any aspect of the package
- ✅ **Custom User Logic** - Custom user filtering and permissions
- ✅ **Custom Message Logic** - Custom validation and filtering
- ✅ **Custom Group Logic** - Custom group creation and management
- ✅ **Custom Events** - Custom broadcasting and event handling
- ✅ **Custom Services** - Extensible service layer architecture
- ✅ **Custom Controllers** - Extend and customize controllers
- ✅ **Custom Views** - Complete UI customization
- ✅ **Custom Routes** - Custom routing and middleware
- ✅ **Custom Database** - Custom migrations and connections

📋 **Requirements**
------------------

[](#-requirements)

- **PHP**: &gt;= 7.4
- **Laravel**: &gt;= 8.0
- **Node.js**: &gt;= 14.0 (for Socket.IO server)
- **Redis**: For broadcasting and caching
- **Database**: MySQL, PostgreSQL, or SQLite

🛠 **Installation**
------------------

[](#-installation)

### 1. **Install Package via Composer**

[](#1-install-package-via-composer)

```
composer require devsfort/laravel-pigeon-chat
```

### 2. **Publish Configuration and Assets**

[](#2-publish-configuration-and-assets)

```
# Publish configuration
php artisan vendor:publish --tag=devschat-config

# Publish migrations
php artisan vendor:publish --tag=devschat-migrations

# Publish views (optional)
php artisan vendor:publish --tag=devschat-views

# Publish controllers (optional)
php artisan vendor:publish --tag=devschat-controllers

# Publish assets
php artisan vendor:publish --tag=devschat-assets

# Publish Node.js server file
php artisan vendor:publish --tag=devschat-server
```

### 3. **Run Migrations**

[](#3-run-migrations)

```
php artisan migrate
```

> **⚠️ Important for Fresh Laravel Installations**: If you're installing this package in a fresh Laravel application (especially with Jetstream), you might encounter foreign key constraint errors. The package now handles this automatically, but if you still get errors, see the [Troubleshooting](#-troubleshooting) section below.

### 4. **Install Node.js Dependencies**

[](#4-install-nodejs-dependencies)

```
# Install dependencies for Socket.IO server
npm install express socket.io ioredis

# Or use the provided package.json
cp package-chat.json package.json
npm install
```

### 5. **Configure Broadcasting**

[](#5-configure-broadcasting)

Update your `.env` file:

```
BROADCAST_DRIVER=redis
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_DB=0
```

### 6. **Start Socket.IO Server**

[](#6-start-socketio-server)

```
# Start the chat server
node server.js
```

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

[](#️-configuration)

### **Environment Variables**

[](#environment-variables)

The package is highly configurable through environment variables:

```
# Basic Configuration
DEVSFORT_NAME="Your Chat App Name"
DEVSFORT_PATH="chat"
DEVSFORT_MIDDLEWARE="auth"

# Socket Configuration
SOCKET_HOST="127.0.0.1"
SOCKET_PORT="8005"

# Redis Configuration
REDIS_CLIENT="predis"
REDIS_HOST="127.0.0.1"
REDIS_PORT="6379"
REDIS_DB="0"

# File Upload Configuration
DEVSFORT_ATTACHMENTS_FOLDER="chat-attachments"
DEVSFORT_ATTACHMENTS_MAX_SIZE="150000000"
DEVSFORT_ALLOWED_IMAGES="png,jpg,jpeg,gif"
DEVSFORT_ALLOWED_FILES="zip,rar,txt,pdf"

# Avatar Configuration
DEVSFORT_USER_AVATAR_FOLDER="user-avatars"
DEVSFORT_USER_AVATAR_DEFAULT="default-avatar.png"
DEVSFORT_GROUP_AVATAR_FOLDER="group-avatars"
DEVSFORT_GROUP_AVATAR_DEFAULT="default-group.png"

# Group Configuration
DEVSFORT_GROUPS_MAX_MEMBERS="100"
DEVSFORT_GROUPS_ALLOW_PRIVATE="true"
DEVSFORT_GROUPS_ALLOW_REMOVAL="true"
DEVSFORT_GROUPS_ALLOW_PROMOTION="true"

# Cache Configuration
DEVSFORT_CACHE_ENABLED="true"
DEVSFORT_CACHE_DRIVER="redis"
DEVSFORT_CACHE_PREFIX="chat"
DEVSFORT_CACHE_TTL="3600"

# API Configuration
DEVSFORT_API_ENABLED="true"
DEVSFORT_API_VERSION="v1"
DEVSFORT_API_RATE_LIMIT="60"
```

### **Customization Configuration**

[](#customization-configuration)

For advanced customization, see the [Customization Guide](CUSTOMIZATION_GUIDE.md):

```
# User Customization
DEVSFORT_USER_MODEL="App\Models\CustomUser"
DEVSFORT_USER_SCOPE="App\Services\CustomUserScope"
DEVSFORT_USER_SERVICE="App\Services\CustomUserService"

# Message Customization
DEVSFORT_MESSAGE_VALIDATOR="App\Validators\CustomMessageValidator"
DEVSFORT_MESSAGE_FILTER="App\Filters\CustomMessageFilter"

# Group Customization
DEVSFORT_GROUP_VALIDATOR="App\Validators\CustomGroupValidator"
DEVSFORT_GROUP_PERMISSION_HANDLER="App\Handlers\CustomGroupPermissionHandler"

# Service Customization
DEVSFORT_CHAT_SERVICE="App\Services\CustomChatService"
DEVSFORT_GROUP_SERVICE="App\Services\CustomGroupService"

# Controller Customization
DEVSFORT_MESSAGES_CONTROLLER="App\Http\Controllers\CustomMessagesController"

# View Customization
DEVSFORT_VIEW_LAYOUT="layouts.custom-chat"
DEVSFORT_VIEW_CHAT="pages.custom-chat"

# Route Customization
DEVSFORT_CUSTOM_ROUTES="routes/custom-chat.php"
DEVSFORT_MIDDLEWARE_CUSTOM='["custom.chat","throttle:60,1"]'
```

🎯 **Quick Start**
-----------------

[](#-quick-start)

### **Basic Usage**

[](#basic-usage)

1. **Access Chat Interface**

    ```
    http://your-app.com/chat

    ```
2. **Send Messages**

    - Click on any user to start a conversation
    - Type your message and press Enter
    - Attach files by clicking the attachment button
3. **Create Groups**

    - Click on the "Groups" tab
    - Click "Create Group"
    - Add members and set group settings

### **API Usage**

[](#api-usage)

```
// Send a message
$response = Http::post('/chat/sendMessage', [
    'id' => $userId,
    'message' => 'Hello!',
    'type' => 'user'
]);

// Create a group
$response = Http::post('/chat/createGroup', [
    'name' => 'My Group',
    'description' => 'Group description',
    'members' => [1, 2, 3],
    'is_private' => false
]);
```

🔧 **Customization**
-------------------

[](#-customization)

### **Why Customize?**

[](#why-customize)

The package is designed to be **highly customizable** because:

- **Business Logic**: Every application has unique requirements
- **User Management**: Different user models and permission systems
- **Content Rules**: Custom validation and moderation needs
- **Integration**: Must work with existing systems
- **Scalability**: Adapt to growing application needs

### **Customization Methods**

[](#customization-methods)

#### **1. Environment Variables (Simple)**

[](#1-environment-variables-simple)

```
# Override basic settings
DEVSFORT_USER_MODEL="App\Models\CustomUser"
DEVSFORT_MESSAGE_VALIDATOR="App\Validators\CustomValidator"
```

#### **2. Class Extension (Recommended)**

[](#2-class-extension-recommended)

```
