About Services Projects Blog Contact
Backend · Published on 2025-01-05

Real-time Features with Pusher & Laravel Broadcasting

How to build a real-time notification and live update system using Laravel Broadcasting and Pusher in mobile apps.

Introduction

Real-time updates have become essential in modern applications. Laravel Broadcasting with Pusher makes this incredibly easy.

Setup

composer require pusher/pusher-php-server

In your .env file:

BROADCAST_DRIVER=pusher
PUSHER_APP_ID=your_id
PUSHER_APP_KEY=your_key
PUSHER_APP_SECRET=your_secret
PUSHER_APP_CLUSTER=mt1

Creating an Event

php artisan make:event OrderStatusUpdated

In the event class:

class OrderStatusUpdated implements ShouldBroadcast
{
    public function broadcastOn() {
        return new PrivateChannel('orders.'.$this->order->id);
    }
}

On Flutter

final pusher = PusherChannelsFlutter.getInstance();
await pusher.init(apiKey: 'key', cluster: 'mt1');
await pusher.connect();
🚀 Start Your Project ← Back to Blog

Related Articles