Real time database || web socket || chat application
Some Helpful Links :
- Tutorials:
- Examples:
- Documentation:
Setup: #1
Steps:
Install fresh Laravel
laravel new blog
setup .env file
Setup: #2 ( Laravel WebSockets )
Install Laravel WebSocketscomposer require beyondcode/laravel-websockets
publish the migration files
php artisan vendor:publish --provider="BeyondCode\LaravelWebSockets\WebSocketsServiceProvider" --tag="migrations"
Run the migrations
php artisan migrate
publish the WebSocket configuration file
php artisan vendor:publish --provider="BeyondCode\LaravelWebSockets\WebSocketsServiceProvider" --tag="config"
This is the default content of the config file that will be published as
config/websockets.php
:'apps' => [ [ 'id' => env('PUSHER_APP_ID'), 'name' => env('APP_NAME'), 'key' => env('PUSHER_APP_KEY'), 'secret' => env('PUSHER_APP_SECRET'), 'enable_client_messages' => false, 'enable_statistics' => true, ], ],
go to .env file and edit with any id, key & secret
PUSHER_APP_ID=anyID PUSHER_APP_KEY=anyKey PUSHER_APP_SECRET=anySecret PUSHER_APP_CLUSTER=mt1
Setup: #3 ( Pusher Replacement )
install the official Pusher PHP SDKcomposer require pusher/pusher-php-server "~3.0"
Next, you should make sure to use Pusher as your broadcasting driver. This can be achieved by setting the
BROADCAST_DRIVER
environment variable in your .env
file:BROADCAST_DRIVER=pusher
When broadcasting events from your Laravel application to your WebSocket server, the default behavior is to send the event information to the official Pusher server. But since the Laravel WebSockets package comes with its own Pusher API implementation, we need to tell Laravel to send the events to our own server.
To do this, you should add the
host
and port
configuration key to your config/broadcasting.php
and add it to the pusher
section. The default port of the Laravel WebSocket server is 6001.'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' ], ],
laravel new blog
laravel new blog
laravel new blog
laravel new blog
laravel new blog
laravel new blog
laravel new blog
laravel new blog
laravel new blog
laravel new blog
laravel new blog
laravel new blog
laravel new blog
laravel new blog
laravel new blog
Install npm
npm install
মন্তব্যসমূহ
একটি মন্তব্য পোস্ট করুন