Answer the question
In order to leave comments, you need to log in
How to use pusher in laravel 5.4?
When trying to send a message, Laravel returns an exception: BroadcastException in PusherBroadcaster.php line 106:
404 NOT FOUND.
event:
<?php
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
class TestEvent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
/**
* Create a new event instance.
*
* @return void
*/
public $text;
public function __construct($text)
{
$this->text=$text;
}
/**
* Get the channels the event should broadcast on.
*
* @return Channel|array
*/
public function broadcastOn()
{
return new PrivateChannel('channel-name');
}
}
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
use App\Events\TestEvent;
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::get('/home', '[email protected]')->name('home');
Route::get('/broadcast', function() {
event(new TestEvent('Test message'));
return view('welcome');
});
Answer the question
In order to leave comments, you need to log in
in general, I messed up everything. Instead of a variable name, I wrote pushera keys.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question