nnixon/laravel-simple-realtime-chat
最新稳定版本:v1.0.0
Composer 安装命令:
composer require nnixon/laravel-simple-realtime-chat
包简介
A simple realtime chat package for Laravel
README 文档
README
A lightweight package for adding realtime chat functionality to your Laravel application.
Features
- One-on-one private conversations
- Group chat support
- Realtime message updates with Pusher
- Read status tracking
- User search functionality
- Responsive UI with TailwindCSS
Requirements
- PHP 8.0+
- Laravel 8.0+
- Pusher account for realtime functionality
Prerequisites
Before installing this package, make sure to set up authentication and required dependencies:
# Install Laravel Breeze for authentication composer require laravel/breeze php artisan breeze:install # Install Pusher PHP Server composer require pusher/pusher-php-server # Install npm dependencies npm install # Install required JavaScript packages npm install lodash laravel-echo pusher-js
Installation
- Install the package via composer:
composer require nnixon/laravel-simple-realtime-chat
- Publish the package files:
php artisan realtime-chat:publish
- Run the migrations:
php artisan migrate
- Uncomment the BroadcastServiceProvider in
config/app.php:
// Uncomment this line in the providers array App\Providers\BroadcastServiceProvider::class,
- Update your
.envfile with Pusher credentials:
BROADCAST_DRIVER=pusher
PUSHER_APP_ID=your-app-id
PUSHER_APP_KEY=your-app-key
PUSHER_APP_SECRET=your-app-secret
PUSHER_APP_CLUSTER=your-app-cluster
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
- Update your
routes/channels.phpfile with the following code:
<?php use App\Models\Conversation; use App\Models\User; use Illuminate\Support\Facades\Broadcast; Broadcast::channel('conversation.{conversationId}', function (User $user, $conversationId) { return $user->conversations->contains(function ($conversation) use ($conversationId) { return $conversation->id == $conversationId; }); });
- Build your frontend assets:
npm run build
Usage
Once installed, you can access the chat interface at:
/conversations- View all conversations/conversations/{id}- View a specific conversation/conversations/create-group- Create a new group conversation
Customization
All views are published to resources/views/realtime-chat and can be customized to match your application's design.
Controllers, models, and other files are published to their respective directories in your application and can be modified as needed.
License
MIT
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-04