So I'm trying to setup broadcasting using redis however I can't get this to work as I'm missing some configuration options I guess.
.env file
...
BROADCAST_DRIVER=redis
...
Controller
event(new TestEvent());
TestEvent.php
<?php
namespace App\Events\Socket;
use App\Events\Event;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
class TestEvent implements ShouldBroadcast
{
protected $data;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct()
{
$this->data = [
'payload' => [
'test' => 'test'
],
'message' => 'another'
];
}
public function broadcastOn()
{
return new PrivateChannel('user.2');
}
}
However, when I run this in my failed_jobs table in the database this error pops up:
Symfony\Component\Debug\Exception\FatalThrowableError: Class 'Pusher' not found in /var/www/vendor/illuminate/broadcasting/BroadcastManager.php:216 Stack trace:
0 /var/www/vendor/illuminate/broadcasting/BroadcastManager.php(193): Illuminate\Broadcasting\BroadcastManager->createPusherDriver(Array)
1 /var/www/vendor/illuminate/broadcasting/BroadcastManager.php(164): Illuminate\Broadcasting\BroadcastManager->resolve('pusher')
2 /var/www/vendor/illuminate/broadcasting/BroadcastManager.php(153): Illuminate\Broadcasting\BroadcastManager->get('pusher')
3 /var/www/vendor/illuminate/broadcasting/BroadcastManager.php(140): Illuminate\Broadcasting\BroadcastManager->driver('pusher')
4 /var/www/vendor/illuminate/broadcasting/BroadcastServiceProvider.php(30): Illuminate\Broadcasting\BroadcastManager->connection()
5 /var/www/vendor/illuminate/container/Container.php(726): Illuminate\Broadcasting\BroadcastServiceProvider->Illuminate\Broadcasting{closure}(Object(Laravel\Lumen\Application), Array)
6 /var/www/vendor/illuminate/container/Container.php(608): Illuminate\Container\Container->build(Object(Closure))
7 /var/www/vendor/illuminate/container/Container.php(575): Illuminate\Container\Container->resolve('Illuminate\Cont...')
8 /var/www/vendor/laravel/lumen-framework/src/Application.php(210): Illuminate\Container\Container->make('Illuminate\Cont...')
9 /var/www/vendor/illuminate/container/BoundMethod.php(156): Laravel\Lumen\Application->make('Illuminate\Cont...')
10 /var/www/vendor/illuminate/container/BoundMethod.php(116): Illuminate\Container\BoundMethod::addDependencyForCallParameter(Object(Laravel\Lumen\Application), Object(ReflectionParameter), Array, Array)
11 /var/www/vendor/illuminate/container/BoundMethod.php(29): Illuminate\Container\BoundMethod::getMethodDependencies(Object(Laravel\Lumen\Application), Array, Array)
12 /var/www/vendor/illuminate/container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container{closure}()
13 /var/www/vendor/illuminate/container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Laravel\Lumen\Application), Array, Object(Closure))
14 /var/www/vendor/illuminate/container/Container.php(539): Illuminate\Container\BoundMethod::call(Object(Laravel\Lumen\Application), Array, Array, NULL)
15 /var/www/vendor/illuminate/bus/Dispatcher.php(94): Illuminate\Container\Container->call(Array)
16 /var/www/vendor/illuminate/pipeline/Pipeline.php(114): Illuminate\Bus\Dispatcher->Illuminate\Bus{closure}(Object(Illuminate\Broadcasting\BroadcastEvent))
17 /var/www/vendor/illuminate/pipeline/Pipeline.php(102): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Broadcasting\BroadcastEvent))
18 /var/www/vendor/illuminate/bus/Dispatcher.php(98): Illuminate\Pipeline\Pipeline->then(Object(Closure))
19 /var/www/vendor/illuminate/queue/CallQueuedHandler.php(42): Illuminate\Bus\Dispatcher->dispatchNow(Object(Illuminate\Broadcasting\BroadcastEvent), false)
20 /var/www/vendor/illuminate/queue/Jobs/Job.php(69): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\DatabaseJob), Array)
21 /var/www/vendor/illuminate/queue/Worker.php(317): Illuminate\Queue\Jobs\Job->fire()
22 /var/www/vendor/illuminate/queue/Worker.php(267): Illuminate\Queue\Worker->process('database', Object(Illuminate\Queue\Jobs\DatabaseJob), Object(Illuminate\Queue\WorkerOptions))
23 /var/www/vendor/illuminate/queue/Worker.php(113): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\DatabaseJob), 'database', Object(Illuminate\Queue\WorkerOptions))
24 /var/www/vendor/illuminate/queue/Console/WorkCommand.php(101): Illuminate\Queue\Worker->daemon('database', 'default', Object(Illuminate\Queue\WorkerOptions))
25 /var/www/vendor/illuminate/queue/Console/WorkCommand.php(85): Illuminate\Queue\Console\WorkCommand->runWorker('database', 'default')
26 [internal function]: Illuminate\Queue\Console\WorkCommand->fire()
27 /var/www/vendor/illuminate/container/BoundMethod.php(29): call_user_func_array(Array, Array)
28 /var/www/vendor/illuminate/container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container{closure}()
29 /var/www/vendor/illuminate/container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Laravel\Lumen\Application), Array, Object(Closure))
30 /var/www/vendor/illuminate/container/Container.php(539): Illuminate\Container\BoundMethod::call(Object(Laravel\Lumen\Application), Array, Array, NULL)
31 /var/www/vendor/illuminate/console/Command.php(182): Illuminate\Container\Container->call(Array)
32 /var/www/vendor/symfony/console/Command/Command.php(262): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
33 /var/www/vendor/illuminate/console/Command.php(167): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
34 /var/www/vendor/symfony/console/Application.php(888): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
35 /var/www/vendor/symfony/console/Application.php(224): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
36 /var/www/vendor/symfony/console/Application.php(125): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
37 /var/www/vendor/laravel/lumen-framework/src/Console/Kernel.php(84): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
38 /var/www/artisan(35): Laravel\Lumen\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
39 {main}
This is strange because it shouldn't event be trying to create the Pusher instance.
I've tried with composer dump-autoload, composer clear-cache, php artisan clear-compiled...
It is funny because if I try this code and dump the instance I get a good configured BroadcastManager:
$broadcastManager = (new BroadcastManager(app()))->connection();
Can anybody help with this?