C
C
Constantine12017-05-17 10:38:56
Laravel
Constantine1, 2017-05-17 10:38:56

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');
    }
}

Routes:
<?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');
});

pusher-php-server package added.
variables added to .ENV
config/broadcasting added app_id, key, secret.
also added BroadcastServiceProvider.
Tell me which way to look?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Constantine1, 2017-05-17
@Constantine1

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 question

Ask a Question

731 491 924 answers to any question