PHP code example of wirelabs / fluxchat

1. Go to this page and download the library: Download wirelabs/fluxchat library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wirelabs / fluxchat example snippets


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

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

// 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'),
    ],
];

// 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',
]);

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

protected $listen = [
    MessageSent::class => [
        SendMessageNotification::class,
    ],
];
bash
php artisan fluxchat:install
bash
php artisan migrate
bash
php artisan vendor:publish --tag="fluxchat-config"
bash
php artisan install:broadcasting
bash
php artisan reverb:start
bash
php artisan vendor:publish --tag="fluxchat-views"
bash
php artisan vendor:publish --tag="fluxchat-lang"
bash
php artisan reverb:start --debug
bash
php artisan config:show broadcasting.default