Laravel 8 Pusher Notification Example Tutorial

Laravel 8 Pusher Notification Example Tutorial

In this tutorial, we will explain to you how to create a pusher notification example in Laravel 8(Laravel 8 Pusher Notification Example Tutorial). Pusher is a well-known service that allows you to send real time notifications to your applications.

In this example, we will integrate the pusher notification in laravel 8 using the “pusher-php-server” package. so you can follow the below step.

Overview
Step 1: Install Laravel
Step 2: Install Package
Step 3: Setup your Pusher Account
Step 4: Create an event
Step 5: Create a Controller
Step 6: Define route in laravel
Step 7: Create view file in laravel
Step 8: Run The Application

Step 1: Install Laravel
We are going to install laravel 8, so first open the command prompt or terminal and go to xampp htdocs folder directory using the command prompt. after then run the below command.

Step 2: Install Package
Now, we are going to install the “pusher/pusher-php-server” package using the below command.

Step 3: Setup your Pusher Account
First, we Must have an account on Pusher.com. if no then please go to the pusher official site and create an account.
After successfully created an account and get the appid, key, secret and cluster. we will set the credentials in the .env file. so you can see our code.

Step 4: Create an event
we need to create the type of event for which it works as a notification send in Laravel. Events can be triggered from anywhere in the application. the file will be created in app/Events directory. so you can create the event class using the below command.

app/Events/Notify.php

Step 5: Create a Controller
Here below command help to create the controller.

PusherNotificationController.php

Step 6: Define route in laravel
Add the following route code in the “routes/web.php” file.

Step 7: Create view file in laravel
So finally, first we will create the student.blade.php files in the “resources/views” directory.
notification.blade.php

Step 8: Run The Application
We can start the server and run this application using the below command.

Now, we will use the below URL to send a notification. so you can open a new tab and visit the “http://localhost:8000/send” notification.

if you want to see the notification then you can see the below URL and open it in another tab and you can see the alert notification.

Please follow and like us: