yes, it uses the pusher javascript library, not the pusher service.
Does Laravel Reverb utilize Pusher?
When using Laravel Reverb, do we need to import Pusher in resources echo.js or remove it? Does Laravel Reverb need to use Pusher for websockets? I thought I read something relative to it. Thanks
@Snapey Ok I assume once we install Echo we leave the Pusher import code in the echo.js file alone. Please let me know otherwise. Thanks for responding!
Laravel Reverb is not a standard or widely recognized package within the Laravel ecosystem. It seems there might be some confusion with Laravel Echo, which is a common tool used for working with WebSockets in Laravel applications.
Laravel Echo can be configured to use various drivers for real-time event broadcasting, one of which is Pusher. However, you can also configure Laravel Echo to use other drivers like Redis with Socket.IO or even Laravel Websockets, which is a completely local WebSocket server implementation that does not rely on any external services like Pusher.
Here's how you can set up Laravel Echo with Pusher:
- Install Pusher and Echo: First, you need to install the necessary packages via npm.
npm install --save laravel-echo pusher-js
-
Configure
broadcasting.php: Make sure yourconfig/broadcasting.phpfile is set up to use Pusher.
'connections' => [
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'useTLS' => true,
],
],
// other connections...
],
-
Configure
.env: Update your.envfile with the correct Pusher credentials.
BROADCAST_DRIVER=pusher
PUSHER_APP_ID=your-app-id
PUSHER_APP_KEY=your-app-key
PUSHER_APP_SECRET=your-app-secret
PUSHER_APP_CLUSTER=your-app-cluster
-
Set up
echo.js: In yourresources/js/bootstrap.jsor a similar file where you set up Echo, make sure it's configured to use Pusher.
import Echo from 'laravel-echo';
window.Pusher = require('pusher-js');
window.Echo = new Echo({
broadcaster: 'pusher',
key: process.env.MIX_PUSHER_APP_KEY,
cluster: process.env.MIX_PUSHER_APP_CLUSTER,
encrypted: true
});
- Compile Assets: Don't forget to compile your assets with Mix.
npm run dev
- Use in Laravel: You can now use Laravel events with broadcasting.
event(new \App\Events\SomeEvent($data));
This setup assumes you are using Pusher as your WebSocket broadcaster. If you are not using Pusher, you would need to adjust the configuration accordingly, possibly removing or replacing the Pusher-specific setup in echo.js and broadcasting.php.
If you meant something else by "Laravel Reverb," please clarify, as it might be a custom or less-known package or service.
I don't seem to have a way to have this work on flutter using the Pusher client keeps complaining about cluster
Please or to participate in this conversation.