定制 wirelabs/fluxchat 二次开发

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

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

wirelabs/fluxchat

Composer 安装命令:

composer require wirelabs/fluxchat

包简介

A beautiful Laravel Livewire chat component built with Flux UI, supporting real-time messaging with Reverb.

README 文档

README

A beautiful Laravel Livewire chat component built with Flux UI, supporting both standard polling and real-time messaging with Laravel Reverb.

FluxChat Preview

✨ Features

  • 🎨 Beautiful UI - Built with Flux UI components
  • Real-time Support - Optional Laravel Reverb integration
  • 🔄 Fallback Polling - Works without WebSocket server
  • 🌍 Multi-language - English and Norwegian included
  • 📱 Responsive Design - Works on all devices
  • 🔧 Highly Configurable - Customize everything
  • 🚀 Easy Installation - One command setup

📋 Requirements

  • PHP 8.3+
  • Laravel 12.0+
  • Livewire 3.0+
  • Flux UI Pro 2.0+

🚀 Installation

Install via Composer:

composer require wirelabs/fluxchat

Run the installation command:

php artisan fluxchat:install

Run migrations:

php artisan migrate

🎯 Basic Usage

Add the component to your Blade view:

<livewire:fluxchat :contacts="$contacts" />

Where $contacts is a collection of users/contacts:

// In your controller
$contacts = User::where('id', '!=', auth()->id())->get();

return view('chat', compact('contacts'));

⚙️ Configuration

Publish the config file:

php artisan vendor:publish --tag="fluxchat-config"

Basic Configuration

// config/fluxchat.php

return [
    'realtime' => [
        'enabled' => env('FLUXCHAT_REALTIME_ENABLED', false),
        'auto_refresh_interval' => env('FLUXCHAT_AUTO_REFRESH', 5), // seconds
    ],
    
    'ui' => [
        'theme' => env('FLUXCHAT_THEME', 'dark'),
        'avatar_size' => env('FLUXCHAT_AVATAR_SIZE', 'sm'),
    ],
];

Environment Variables

Add to your .env file:

# Standard mode (polling every 5 seconds)
FLUXCHAT_REALTIME_ENABLED=false
FLUXCHAT_AUTO_REFRESH=5

# Real-time mode (requires Reverb)
FLUXCHAT_REALTIME_ENABLED=true
BROADCAST_CONNECTION=reverb

🔥 Real-time Messaging

FluxChat supports two modes:

1. Standard Mode (Default)

  • Polls for new messages every 5 seconds
  • No additional server required
  • Works everywhere

2. Real-time Mode

  • Instant message delivery via WebSockets
  • Requires Laravel Reverb
  • Better user experience

To enable real-time messaging:

  1. Install and configure Laravel Reverb:
php artisan install:broadcasting
  1. Update your .env:
FLUXCHAT_REALTIME_ENABLED=true
BROADCAST_CONNECTION=reverb
  1. Start the Reverb server:
php artisan reverb:start

🎨 Customization

Custom Contact Model

<livewire:fluxchat 
    :contacts="$contacts"
    contact-model="App\Models\Contact"
    contact-name-field="full_name"
    :contact-search-fields="['name', 'email']"
/>

Custom Styling

Publish the views to customize:

php artisan vendor:publish --tag="fluxchat-views"

Views will be published to resources/views/vendor/fluxchat/.

Language Customization

Publish language files:

php artisan vendor:publish --tag="fluxchat-lang"

Add your own translations in resources/lang/vendor/fluxchat/.

📚 Advanced Usage

Programmatic Control

// In your Livewire component
use Wirelabs\FluxChat\Models\Conversation;
use Wirelabs\FluxChat\Models\Message;

// Create a conversation
$conversation = Conversation::create([
    'type' => 'private',
    'is_group' => false,
]);

// Add participants
$conversation->addParticipant(auth()->user());
$conversation->addParticipant($contact);

// Send a message
$message = $conversation->messages()->create([
    'sendable_id' => auth()->id(),
    'sendable_type' => User::class,
    'body' => 'Hello!',
    'type' => 'text',
]);

Events

Listen to FluxChat events:

// EventServiceProvider
use Wirelabs\FluxChat\Events\MessageSent;

protected $listen = [
    MessageSent::class => [
        SendMessageNotification::class,
    ],
];

🧪 Testing

composer test

📖 API Reference

Component Properties

Property Type Default Description
contacts Collection/Array [] Available contacts
contactModel String User::class Contact model class
contactNameField String 'name' Contact name field
contactSearchFields Array ['name'] Searchable fields
maxContacts Integer 10 Max contacts to show

Models

Conversation

  • messages() - Get all messages
  • participants() - Get all participants
  • addParticipant($user) - Add participant
  • markAsRead($user) - Mark as read

Message

  • conversation() - Get conversation
  • sendable() - Get sender
  • isEdited() - Check if edited

🛠️ Troubleshooting

Real-time not working

  1. Check Reverb is running:
php artisan reverb:start --debug
  1. Verify configuration:
php artisan config:show broadcasting.default
  1. Check browser console for WebSocket connections

Messages not updating

  1. Ensure auto-refresh is enabled:
FLUXCHAT_AUTO_REFRESH=5
  1. Check Livewire is working:
@livewireScripts

🤝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for details.

📄 License

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

🙏 Credits

Made with ❤️ by Wirelabs

wirelabs/fluxchat 适用场景与选型建议

wirelabs/fluxchat 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 07 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「real-time」 「messaging」 「chat」 「laravel」 「livewire」 「reverb」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 wirelabs/fluxchat 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 wirelabs/fluxchat 我们能提供哪些服务?
定制开发 / 二次开发

基于 wirelabs/fluxchat 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-13