This is an online chat room sample project in Laravel using websockets.
Clone this repository by running
git clone https://github.com/sinakhaghani/laravel-websocket-chatroom.gitInstall the packages by running the composer install command
composer installInstall JavaScript dependencies and install tailwind css in your project
npm installSet your database credentials in the .env file
Run the migrations
php artisan migrateSet the Pusher app credentials in the .env as follows
PUSHER_APP_ID=your_app_id
PUSHER_APP_KEY=your_app_key
PUSHER_APP_SECRET=your_app_secret
PUSHER_APP_CLUSTER=mt1
Set your PUSHER_APP_KEY in resources/js/bootstrap.js file
window.Echo = new Echo({
broadcaster: 'pusher',
key: 'your_app_key',
wsHost: window.location.hostname,
wsPort: 6001,
forceTLS: false,
disableStats: true,
});
Set the BROADCAST_DRIVER variable in the .env file to pusher
BROADCAST_DRIVER=pusher
Run the laravel
php artisan serveRun the websockets
php artisan websocket:serveGo to the following url and connect websockets
localhost:8000/laravel-websockets
Now the project is ready to use
localhost:8000/rooms