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..
devsfort/laravel-pigeon-chat is a Laravel package for 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...
It currently has 9 GitHub stars and 31 downloads on Packagist (latest version v2.1.7).
Install it with composer require devsfort/laravel-pigeon-chat.
Discover more Laravel packages by devsfort
or browse all Laravel packages to compare alternatives.
Last updated

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.
composer require devsfort/laravel-pigeon-chat
# 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
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 section below.
# 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
Update your .env file:
BROADCAST_DRIVER=redis
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_DB=0
# Start the chat server
node server.js
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"
For advanced customization, see the Customization Guide:
# 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"]'
Access Chat Interface
http://your-app.com/chat
Send Messages
Create Groups
// 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
]);
The package is designed to be highly customizable because:
# Override basic settings
DEVSFORT_USER_MODEL="App\Models\CustomUser"
DEVSFORT_MESSAGE_VALIDATOR="App\Validators\CustomValidator"
<?php
namespace App\Services;
use DevsFort\Pigeon\Chat\Library\BaseChatService;
class CustomChatService extends BaseChatService
{
public function getUsersForChat($excludeCurrentUser = true)
{
$query = parent::getUsersForChat($excludeCurrentUser);
// Add custom logic
$query->where('company_id', auth()->user()->company_id);
$query->where('active_status', 1);
return $query->get();
}
}
<?php
namespace App\Validators;
class CustomMessageValidator
{
public function validate($data)
{
// Custom validation logic
return ['valid' => true, 'errors' => []];
}
}
See the Examples Directory for complete implementation examples:
CustomUserScope.php - User filtering examplesCustomUserService.php - User service examplesCustomMessageValidator.php - Message validation examplesCustomGroupValidator.php - Group validation examplesFor comprehensive customization information, see:
๐ก Pro Tip: Start with the Customization Summary for an overview, then dive into the Customization Guide for detailed implementation steps.
src/
โโโ ChatServiceProvider.php # Service provider
โโโ config/
โ โโโ devschat.php # Configuration file
โโโ database/
โ โโโ migrations/ # Database migrations
โโโ Events/ # Broadcasting events
โโโ Facade/
โ โโโ Chat.php # Facade for easy access
โโโ Http/
โ โโโ Controllers/ # Controllers
โโโ Library/
โ โโโ BaseChatService.php # Extensible base service
โ โโโ DevsFortChat.php # Default implementation
โโโ Models/ # Eloquent models
โโโ routes/
โ โโโ web.php # Route definitions
โโโ views/ # Blade templates
โโโ assets/ # CSS, JS, images
BaseChatService - Extensible service layerPrivateMessageEvent - Broadcasting eventsMessagesController - Main controllerGroup & GroupMember - Group management modelsusers - User information and preferencesmessages - Chat messages with attachmentsfavorites - Favorite conversationsgroups - Group informationgroup_members - Group membership and roles// User can have many messages
User -> hasMany(Message)
// Group has many members
Group -> belongsToMany(User, 'group_members')
// Message belongs to sender and receiver
Message -> belongsTo(User, 'from_id')
Message -> belongsTo(User, 'to_id')
user-chat - Individual user messagesgroup-chat - Group chat messagesuser-status - User online/offline statustyping-indicators - Real-time typing notificationsmessage-seen - Message read confirmations# Test basic functionality
php artisan serve
# Visit: http://localhost:8000/chat
# Test Socket.IO server
node server.js
# Server should start on port 8005
# Test Redis connection
redis-cli ping
# Should return: PONG
<?php
namespace Tests;
use DevsFort\Pigeon\Chat\Library\DevsFortChat;
class ChatTest extends TestCase
{
public function test_custom_user_service()
{
$chatService = new CustomChatService();
$users = $chatService->getUsersForChat();
$this->assertNotEmpty($users);
}
}
Migration Errors (Foreign Key Constraints)
SQLSTATE[HY000]: General error: 1005 Can't create table 'groups' (errno: 150 "Foreign key constraint is incorrectly formed")php artisan migrate:fresh
# Then install the package
composer require devsfort/laravel-pigeon-chat
php artisan vendor:publish --tag=devschat-migrations
php artisan migrate
Messages Not Sending
Users Not Loading
Group Creation Fails
Real-time Not Working
# Enable debug mode
APP_DEBUG=true
# Check logs
tail -f storage/logs/laravel.log
# Check Redis
redis-cli monitor
# Check Socket.IO
# Monitor server.js console output
# Clone repository
git clone https://github.com/your-username/laravel-pigeon-chat.git
# Install dependencies
composer install
npm install
# Run tests
php artisan test
# Build assets
npm run build
This package is open-sourced software licensed under the MIT license.
Haseeb Ahmad - [email protected]
โญ Star this repository if you find it helpful!
๐ง Need customization help? Check the Customization Guide for comprehensive examples and instructions.
๐ Ready to get started? Follow the installation steps above and begin building your custom chat solution!