This talk will explore two possible solutions for adding real-time functionality to Laravel applications: Laravel Echo with Laravel Reverb and Pusher. It will examine their architecture, ease of integration, performance, scalability, and costs to help you choose the solution that best suits your needs.
Use Composer and NPM to install all required packages:
composer install
npm install
Copy .env.example
to .env
and adjust the configuration according to your environment.
Run the Vite development server to enable frontend features:
npm run dev
Use the Artisan command to start the Reverb server:
php artisan reverb:start
To toggle between Pusher and Reverb for broadcasting, update the following lines in your .env
file:
# For Reverb
BROADCAST_CONNECTION=reverb
BROADCAST_DRIVER=reverb
# For Pusher
BROADCAST_CONNECTION=pusher
BROADCAST_DRIVER=pusher
After updating .env
, make sure to clear the configuration cache for the changes to take effect:
php artisan config:cache
The homepage (/
) includes links in the header to access the Reverb Dashboard
and Pusher Dashboard
. Use these
dashboards
to observe real-time updates triggered by the commands below.
php artisan orders:create {count=5}
This command generates the specified number of new orders (default: 5). The new orders will appear automatically on the dashboard, allowing you to test real-time order updates.
php artisan orders:change {id}
This command changes the status of a specified order by its ID. The status automatically transitions as follows:
- From new to delivering
- From delivering to delivered
As the status changes, the order’s position on the dashboard updates in real time.
php artisan orders:delete
This command deletes all orders from the database. To fully reset the dashboard view, click the “Clear” button on the dashboard, which removes all displayed orders. This allows you to refresh the dashboard before testing new orders and status changes.
Offline Agency is a web design agency based in Padua, Italy. You'll find an overview of our projects on our website.