Laravel live chat pusher js, bootstrap, javascript, jquery

Overview

Build Status Total Downloads Latest Stable Version License

Documentation

First of all install a laravel project. Then install a authentication system like, auth, breze, Jetstream etc. Then you need a model, Called Message.

Then, If you plan to broadcast your events using Pusher Channels, you should install the Pusher Channels PHP SDK using the Composer package manager:

{
   composer require pusher/pusher-php-server.
}

After That Run the following command:

{
   npm install --save-dev laravel-echo pusher-js
}

Next, you should configure your Pusher Channels credentials in the config/broadcasting.php configuration file. An example Pusher Channels configuration is already included in this file, allowing you to quickly specify your key, secret, and application ID. Typically, these values should be set via the PUSHER_APP_KEY, PUSHER_APP_SECRET, and PUSHER_APP_ID environment variables:

Environment variables

  • PUSHER_APP_ID=your-pusher-app-id
  • PUSHER_APP_KEY=your-pusher-key
  • PUSHER_APP_SECRET=your-pusher-secret
  • PUSHER_APP_CLUSTER=mt1

The config/broadcasting.php file's pusher configuration also allows you to specify additional options that are supported by Channels, such as the cluster.

Next, you will need to change your broadcast driver to pusher in your .env file:

  • BROADCAST_DRIVER=pusher

Event

Then make a event by using the following command

  • php artisan make:event EventName

Then pass data in the database and event

        public function sendMessage(Request $request)
        {
            $from = Auth::id();
            $to = $request->recever_id;

            $data = new Message();
            $data->from = $from;
            $data->to = $request->recever_id;
            $data->message = $request->message;
            $data->is_read = 0;
            $data->save();


            event(new MessageEvent($from, $to));
            return ['success' => true];
        }

After that configure the event

class MessageEvent implements ShouldBroadcast

{
   use Dispatchable, InteractsWithSockets, SerializesModels;

    public $from;
    public $to;
    public function __construct($from, $to)
    {
        $this->from = $from;
        $this->to = $to;
    }

    public function broadcastOn()
    {
        return new Channel('chat');
    }
    public function broadcastAs()
    {
        return 'message';
    }

}

Then go to the resources/js/bootstrap.js file and write the below code

  import Echo from 'laravel-echo';
    import Pusher from 'pusher-js';

    window.Pusher = Pusher;

    window.Echo = new Echo({
        broadcaster: 'pusher',
        key: import.meta.env.VITE_PUSHER_APP_KEY,
        cluster: import.meta.env.VITE_PUSHER_APP_CLUSTER,
        forceTLS: true
    });
You might also like...
Mibew Messenger - open-source live support application written in PHP and MySQL

Mibew Messenger is an open-source live support application written in PHP and MySQL. It enables one-on-one chat assistance in real-time directly from your website.

PHP backend Scripts to add and Manage Live tv Streaming android app
PHP backend Scripts to add and Manage Live tv Streaming android app

PHP Backend to Manage Live TV Streaming Android app Follow Given Steps to Setup Local Environment to run this php Script Setting Up Local Environment

This app aims to benchmark several video/live streaming OTT platforms
This app aims to benchmark several video/live streaming OTT platforms

video-platform-bench This app aims to benchmark several video/live streaming OTT platforms based on Encoding Time performance and provide also a "Time

Repositório do sistema de Chat em RealTime utilizando WebSocket com Laravel, Vue.js, Inertia e Tailwind

Antes de mais nada... Deixa a estrelinha no repositório Me segue aqui no github Aula desse Projeto no YouTube Esse projeto foi desenvolvido por Gustav

Aplikasi chat dengan laravel dan react

Aplikasi Chat Stack Laravel 8 ReactJs InertiaJs Deskripsi Aplikasi Chat yang menggunakan Backend Laravel dan Frontend React. Namun, karena saya malas

A Real time chat app made in Next.js, Laravel and Ably.

Chat App with Next.js, Laravel and Ably This repository serves as a code container for the tutorial I wrote on Ably's Blog. Blog link will be updated

Um chat web feito com HTML, CSS, SASS, JS, PHP e MYSQL

ChatWeb Tecnologias Front-end usadas: Pré processador CSS: Linguagem de programação usada: Projeto hospedado no: Editor de texto usado: Objetivos: Par

PHP, MySQL and JS based web chat application
PHP, MySQL and JS based web chat application

About The Project Chat Application coded in PHP, CSS3 and JS. This is just a project to learn and improve understanding on certain topics. This is not

Chat Application
Chat Application

The system implements oop in most of its core. The users should login, create accounts, start chats with other users and be able to chat freely with the users .Creation of tables is automated here where two users that want to chat have a table.

Owner
Ariful Sikder
Jr. Laravel Developer
Ariful Sikder
A live chat which utilises Socket.io and validates messages sent against a MySQL Table.

Socket.io Shoutbox with MySQL Validation The purpouse of this demonstration is to allow users to enter messages in either a public or private chat. Th

Jefff 9 Oct 14, 2022
Online personal and group chat application using HTML, CSS, JS, PHP,SQL and AJAX that allows users to create own groups, chat

Online personal and group chat application using HTML, CSS, JS, PHP,SQL and AJAX that allows users to create own groups, chat, make friends, check new notifications and edit functionality. Chat automatically updates using AJAX to allow for real-time chatting with other users collected from the database.

Dave Sharma 2 Aug 5, 2022
Created simple login system and chat type website using mysql database along with php and html , css and javascript.

Created simple login system and chat type website using mysql database along with php and html , css and javascript.

null 1 Jan 6, 2022
A Responsive Web Chat App Using Php , MySql and JavaScript

Web-Chat-App A Responsive Web Chat App Using Php , MySql and JavaScript Prerequisites XAMPP [Php Runtime Environment] click HERE To Download XAMPP Set

Luttapi 4 Jul 12, 2022
Frontend repository of libreoupas project, mostly written in PHP and JavaScript, using Bootstrap for responsivity.

libreoupas Description libreoupas est un site Internet permettant aux étudiant de la Faculté des Sciences et Technologies de Vandoeuvre-Lès-Nancy d'av

Clément Colné 4 Jan 6, 2022
Aplikasi Point of Sale berbasis website menggunakan PHP native, Vanila Javascript , Bootstrap 5, Datatables dan MySQL

POS adalah sebuah aplikasi point of sale berbasis website yang dibangun menggunakan tech stack JS - PHP - MySQL.

Oka R. Abdillah 2 Feb 12, 2022
Complete Login and Registration system using HTML, CSS, JAVASCRIPT, BOOTSTRAP, PHP and MYSQL

Complete Login and Registration system using HTML, CSS, JAVASCRIPT, BOOTSTRAP, PHP and MYSQL

JehanKandy 11 Jul 13, 2022
Vote based Question & Answer site built using Laravel 5.4, material design, x-editable and jQuery Upvote with email and database notifications.

About Vote based Question & Answer site built using Laravel 5.4, material design, x-editable, jQuery Upvote and email/database notifications. Register

Jorge A. Gonzalez 116 Nov 2, 2022
Vote based Question & Answer site built using Laravel 5.4, material design, x-editable and jQuery Upvote with email and database notifications.

About Vote based Question & Answer site built using Laravel 5.4, material design, x-editable, jQuery Upvote and email/database notifications. Register

Jorge A. Gonzalez 116 Nov 2, 2022
Hotel Management System using MySQL, Php, Ajax, Jquery and HTML

Hotel-Management-System-Ajax-PHP-Mysql A hotel management system in which clients can perform operations such as booking a room and event. It is possi

vengadesh ks 2 Jun 6, 2022