定制 mevadakalpesh/chatapp 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

mevadakalpesh/chatapp

Composer 安装命令:

composer require mevadakalpesh/chatapp

包简介

Empower your Laravel applications with real-time chat functionality using mevadakalpesh/chatapp. A seamless and customizable solution for enhancing user communication.

README 文档

README

ChatApp is a simple and flexible chat application package built using LiveWire and Beyond WebSocket. It provides real-time chat functionality for web applications, making it easy to integrate and customize according to your project requirements.

Features

  • Real-time chat functionality.
  • Built with LiveWire for seamless server-side rendering.
  • Beyond WebSocket for efficient WebSocket communication.
  • Easy integration and customization.

Installation

You can install the package via composer if this command give error add :dev-main at last as a version:

composer require mevadakalpesh/chatapp

Add This Provider in Providers in config/app.php after installing the package

Mevadakalpesh\ChatApp\ChatAppServiceProviders

You can publish the config file with:

php artisan vendor:publish --provider="Mevadakalpesh\ChatApp\ChatAppServiceProvider" --tag=chatapp

Add this code in your package.json

"dependencies": {
		.......

        "emojionearea": "^3.4.2",
        "laravel-echo": "^1.15.3",
        "pusher-js": "^8.4.0-rc2"

        .......
}

after adding this,run this command

npm install

after that make a model by run this command

php artisan make:model Message

and replace this code in the Message model

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Message extends Model
{
    use HasFactory;
    protected $guarded = [];
}

Add or replace this code in the resources/js/bootstrap.js

import Echo from 'laravel-echo';

import Pusher from 'pusher-js';
window.Pusher = Pusher;

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: import.meta.env.VITE_PUSHER_APP_KEY,
    cluster: import.meta.env.VITE_PUSHER_APP_CLUSTER ?? 'mt1',
    wsHost: import.meta.env.VITE_PUSHER_HOST ? import.meta.env.VITE_PUSHER_HOST : `ws-${import.meta.env.VITE_PUSHER_APP_CLUSTER}.pusher.com`,
    wsPort: import.meta.env.VITE_PUSHER_PORT ?? 80,
    wssPort: import.meta.env.VITE_PUSHER_PORT ?? 443,
    forceTLS: (import.meta.env.VITE_PUSHER_SCHEME ?? 'https') === 'https',
    enabledTransports: ['ws', 'wss'],
});

change or add this some ENV variables

BROADCAST_DRIVER=pusher


PUSHER_APP_ID=LOGICID
PUSHER_APP_KEY=LOGICWI828
PUSHER_APP_SECRET=KSK8372U
PUSHER_HOST=127.0.0.1
PUSHER_PORT=6001
PUSHER_SCHEME=http
PUSHER_APP_CLUSTER=mt1

run this command for start websockets

php artian route:clear
php artisan route:clear
php artisan websockets:ser

now test the chat app by entering this url http://127.0.0.1:8001/chat-app/

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2024-06-10