mtallalmansoor786/chat-package
Composer 安装命令:
composer require mtallalmansoor786/chat-package
包简介
Peer-to-peer chat package for Laravel with Pusher support - Real-time messaging with chat rooms and vertical peer tables
README 文档
README
A peer-to-peer chat package for Laravel with real-time messaging using Pusher. This package provides a complete chat solution with chat rooms, peer management, and real-time message broadcasting.
Features
- ✅ Peer-to-peer chat rooms
- ✅ Real-time messaging with Pusher
- ✅ Vertical peer table for each chat room
- ✅ Bootstrap 5 UI
- ✅ Auto-detects parent project's database connection
- ✅ Reads Pusher configuration from parent project's .env file
- ✅ Composer-based installation
- ✅ SOLID Principles - Follows all SOLID principles for maintainable code
- ✅ Repository Pattern - Clean separation of data access and business logic
- ✅ Service Layer - Business logic separated from controllers
- ✅ Dependency Injection - Interfaces and implementations properly bound
Installation
Method 1: Composer Require (Recommended - After Publishing)
Once published to Packagist or a Git repository:
composer require mtallalmansoor786/chat-package
Then:
- Add Pusher credentials to
.env - Run
php artisan migrate - Access
/chat
That's it! Works like any other Composer package.
Method 2: Local Development (Current Project)
This package is already installed in the current project. See INSTALLATION.md for details.
Method 3: Copy Package (Before Publishing)
To use this package in a different Laravel project before publishing:
- QUICK_START.md - Fast 5-minute setup guide
- INSTALLATION_OTHER_PROJECTS.md - Detailed installation guide
Publishing to Composer
Want to make it installable via composer require? See:
- SETUP_FOR_COMPOSER.md - Quick 5-minute setup guide
- PUBLISH_TO_COMPOSER.md - Complete publishing guide (Packagist, Private Repos, etc.)
Quick Steps:
- Push package to GitHub
- Submit to Packagist (or use private repo)
- Install anywhere with:
composer require mtallalmansoor786/chat-package
Installation (Existing Project)
Step 1: Install via Composer
Add the package to your Laravel project's composer.json:
{
"repositories": [
{
"type": "path",
"url": "./packages/chat-package"
}
],
"require": {
"mtallalmansoor786/chat-package": "*"
}
}
Then run:
composer require mtallalmansoor786/chat-package
Step 2: Configure Pusher
Add your Pusher credentials to your .env file:
PUSHER_APP_ID=your_app_id PUSHER_APP_KEY=your_app_key PUSHER_APP_SECRET=your_app_secret PUSHER_APP_CLUSTER=your_cluster BROADCAST_DRIVER=pusher
Step 3: Publish Configuration (Optional)
php artisan vendor:publish --tag=chat-package-config
Step 4: Run Migrations
The package will automatically use your parent project's database connection. Run migrations:
php artisan migrate
Step 5: Install Pusher PHP SDK (if not already installed)
composer require pusher/pusher-php-server
Usage
Access Chat Interface
Once installed, you can access the chat interface at:
/chat
Create Chat Rooms
Users can create chat rooms and add peers. Each chat room displays:
- Messages in real-time
- Vertical table of peers (users) in the room
- Online/offline status
API Routes
The package provides the following routes (all prefixed with /chat):
GET /chat- Chat rooms listGET /chat/room/{roomId}- View specific chat roomPOST /chat/room/create- Create new chat roomPOST /chat/room/{roomId}/message- Send messageGET /chat/room/{roomId}/messages- Get messages (API)GET /chat/room/{roomId}/peers- Get peers (API)
Configuration
The package automatically reads Pusher configuration from your parent project's .env file. No additional configuration is needed unless you want to customize:
// config/chat-package.php return [ 'pusher' => [ 'app_id' => env('PUSHER_APP_ID'), 'key' => env('PUSHER_APP_KEY'), 'secret' => env('PUSHER_APP_SECRET'), 'cluster' => env('PUSHER_APP_CLUSTER', 'mt1'), 'useTLS' => true, ], 'chat' => [ 'per_page' => 50, 'max_message_length' => 1000, ], ];
Database Tables
The package creates the following tables:
chat_rooms- Stores chat room informationchat_room_user- Pivot table for room members (peers)messages- Stores chat messages
All tables use your parent project's default database connection automatically.
Architecture
This package follows SOLID principles and implements the Repository Pattern:
- Single Responsibility: Each class has one clear purpose
- Open/Closed: Open for extension, closed for modification
- Liskov Substitution: Interfaces can be swapped with implementations
- Interface Segregation: Focused, client-specific interfaces
- Dependency Inversion: Depend on abstractions, not concretions
Code Structure
src/
├── Http/
│ ├── Controllers/ # HTTP request handling
│ └── Requests/ # Form validation
├── Repositories/
│ ├── Contracts/ # Repository interfaces
│ └── [Repository].php # Repository implementations
├── Services/
│ ├── Contracts/ # Service interfaces
│ └── ChatService.php # Business logic
├── Models/ # Eloquent models
└── Exceptions/ # Custom exceptions
See SOLID_PRINCIPLES.md for detailed documentation.
Requirements
- Laravel 12+
- PHP 8.2+
- Pusher account and credentials
- Bootstrap 5 (for UI)
License
MIT
mtallalmansoor786/chat-package 适用场景与选型建议
mtallalmansoor786/chat-package 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「real-time」 「messaging」 「chat」 「laravel」 「pusher」 「peer-to-peer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mtallalmansoor786/chat-package 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mtallalmansoor786/chat-package 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mtallalmansoor786/chat-package 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Talk is a Laravel based realtime messaging, chatting and conversation system. It helps to develop users messaging, chatting and conversations in easy way.
This simple PHP class allows you to easily generate Smartsupp.com JS chat code.
Client for the REST API plugin of the OpenFire Server
Boxalino Real Time User Experience (RTUX) Magento2 plugin
Laravel package for generating Agora.io tokens (RTC, RTM, Chat) with support for both V1 and V2 token formats
PHP library for Broadcastt HTTP API
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-18