承接 nnixon/laravel-simple-realtime-chat 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

  1. Install the package via composer:
composer require nnixon/laravel-simple-realtime-chat
  1. Publish the package files:
php artisan realtime-chat:publish
  1. Run the migrations:
php artisan migrate
  1. Uncomment the BroadcastServiceProvider in config/app.php:
// Uncomment this line in the providers array
App\Providers\BroadcastServiceProvider::class,
  1. Update your .env file 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}"
  1. Update your routes/channels.php file 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;
    });
});
  1. 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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-04