Skip to content

This is the messenger developed in laravel using laravel-websocket. instant message can sent between two users.

Notifications You must be signed in to change notification settings

bedus-creation/laravel-real-demo

Repository files navigation

Demo

https://www.youtube.com/watch?v=GGtCVVwDyWs

  1. Install laravel-websockets
composer require beyondcode/laravel-websockets
  1. Publish the migration file
php artisan vendor:publish --provider="BeyondCode\LaravelWebSockets\WebSocketsServiceProvider" --tag="migrations"
  1. Migrate
php artisan migrate
  1. publish the WebSocket configuration file:
php artisan vendor:publish --provider="BeyondCode\LaravelWebSockets\WebSocketsServiceProvider" --tag="config"
  1. change In .env file
BROADCAST_DRIVER=pusher
PUSHER_APP_ID=LaravelReal
PUSHER_APP_KEY=LaravelReal
PUSHER_APP_SECRET=LaravelRealSecret
PUSHER_APP_CLUSTER=mt1
  1. Uncomment Boardcast service provider in config/app.php
App\Providers\BroadcastServiceProvider::class,
  1. Add this line to boardcast message in routes/channel.php
Broadcast::channel('messages', function () {
    return true;
});
  1. Define port and host in config/boardcasting.php
'pusher' => [
    'driver' => 'pusher',
    'key' => env('PUSHER_APP_KEY'),
    'secret' => env('PUSHER_APP_SECRET'),
    'app_id' => env('PUSHER_APP_ID'),
    'options' => [
        'cluster' => env('PUSHER_APP_CLUSTER'),
        'encrypted' => true,
        'host' => '127.0.0.1',
        'port' => 6001,
        'scheme' => 'http'
    ],
],
  1. Install Laravel echo
npm install --save laravel-echo pusher-js
  1. Define port and host in resources/js/bootstrap.js
window.Echo = new Echo({
    broadcaster: 'pusher',
    key: 'LaravelReal',
    wsHost: window.location.hostname,
    wsPort: 6001,
    disableStats: true,
});
  1. Run
php artisan websocket:serve

About

This is the messenger developed in laravel using laravel-websocket. instant message can sent between two users.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published