未找到Laravel Lumen + Broadcasting + Redis + Class pusher

时间:2018-04-16 11:33:01

标签: laravel lumen

所以我尝试使用redis设置广播但是我无法让它工作,因为我错过了一些配置选项。

.env文件

...
BROADCAST_DRIVER=redis
...

控制器

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

但是,当我在数据库的failed_jobs表中运行此错误时,会弹出以下错误:

Symfony \ Component \ Debug \ Exception \ FatalThrowableError:Class&#39; Pusher&#39;在/var/www/vendor/illuminate/broadcasting/BroadcastManager.php:216中找不到 堆栈跟踪:

0 /var/www/vendor/illuminate/broadcasting/BroadcastManager.php(193):Illuminate \ Broadcasting \ BroadcastManager-&gt; createPusherDriver(Array)

1 /var/www/vendor/illuminate/broadcasting/BroadcastManager.php(164):Illuminate \ Broadcasting \ BroadcastManager-&gt; resolve(&#39; pusher&#39;)

2 /var/www/vendor/illuminate/broadcasting/BroadcastManager.php(153):Illuminate \ Broadcasting \ BroadcastManager-&gt; get(&#39; pusher&#39;)

3 /var/www/vendor/illuminate/broadcasting/BroadcastManager.php(140):Illuminate \ Broadcasting \ BroadcastManager-&gt; driver(&#39; pusher&#39;)

4 /var/www/vendor/illuminate/broadcasting/BroadcastServiceProvider.php(30):Illuminate \ Broadcasting \ BroadcastManager-&gt; connection()

5 /var/www/vendor/illuminate/container/Container.php(726):Illuminate \ Broadcasting \ BroadcastServiceProvider-&gt; Illuminate \ Broadcasting {closure}(Object(Laravel \ Lumen \ Application),Array)

6 /var/www/vendor/illuminate/container/Container.php(608):Illuminate \ Container \ Container-&gt; build(Object(Closure))

7 /var/www/vendor/illuminate/container/Container.php(575):Illuminate \ Container \ Container-&gt;解决(&#39; Illuminate \ Cont ...&#39;)

8 /var/www/vendor/laravel/lumen-framework/src/Application.php(210):Illuminate \ Container \ Container-&gt; make(&#39; Illuminate \ Cont ...&#39; )

9 /var/www/vendor/illuminate/container/BoundMethod.php(156):Laravel \ Lumen \ Application-&gt; make(&#39; Illuminate \ Cont ...&#39;)

10 /var/www/vendor/illuminate/container/BoundMethod.php(116):Illuminate \ Container \ BoundMethod :: addDependencyForCallParameter(Object(Laravel \ Lumen \ Application),Object(ReflectionParameter),Array,Array)< / H1>

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-&gt; call(Array)

16 /var/www/vendor/illuminate/pipeline/Pipeline.php(114):Illuminate \ Bus \ Dispatcher-&gt; Illuminate \ Bus {closure}(Object(Illuminate \ Broadcasting \ BroadcastEvent))

17 /var/www/vendor/illuminate/pipeline/Pipeline.php(102):Illuminate \ Pipeline \ Pipeline-&gt; Illuminate \ Pipeline {closure}(Object(Illuminate \ Broadcasting \ BroadcastEvent))

18 /var/www/vendor/illuminate/bus/Dispatcher.php(98):Illuminate \ Pipeline \ Pipeline-&gt; then(Object(Closure))

19 /var/www/vendor/illuminate/queue/CallQueuedHandler.php(42):Illuminate \ Bus \ Dispatcher-&gt; dispatchNow(Object(Illuminate \ Broadcasting \ BroadcastEvent),false)

20 /var/www/vendor/illuminate/queue/Jobs/Job.php(69):Illuminate \ Queue \ CallQueuedHandler-&gt; call(Object(Illuminate \ Queue \ Jobs \ DatabaseJob),Array)

21 /var/www/vendor/illuminate/queue/Worker.php(317):Illuminate \ Queue \ Jobs \ Job-&gt; fire()

22 /var/www/vendor/illuminate/queue/Worker.php(267):Illuminate \ Queue \ Worker-&gt;进程(&#39;数据库&#39;,对象(Illuminate \ Queue \ Jobs \ DatabaseJob) ),Object(Illuminate \ Queue \ WorkerOptions))

23 /var/www/vendor/illuminate/queue/Worker.php(113):Illuminate \ Queue \ Worker-&gt; runJob(Object(Illuminate \ Queue \ Jobs \ DatabaseJob),&#39; database&#39; ;,Object(Illuminate \ Queue \ WorkerOptions))

24 /var/www/vendor/illuminate/queue/Console/WorkCommand.php(101):照亮\ Queue \ Worker-&gt;守护进程(&#39;数据库&#39;,&#39;默认&#39 ;,Object(Illuminate \ Queue \ WorkerOptions))

25 /var/www/vendor/illuminate/queue/Console/WorkCommand.php(85):Illuminate \ Queue \ Console \ WorkCommand-&gt; runWorker(&#39;数据库&#39;,&#39;默认& #39)

26 [内部功能]:Illuminate \ Queue \ Console \ WorkCommand-&gt; 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-&gt; call(Array)

32 /var/www/vendor/symfony/console/Command/Command.php(262):Illuminate \ Console \ Command-&gt; execute(Object(Symfony \ Component \ Console \ Input \ ArgvInput),Object(Illuminate) \控制台\ OutputStyle))

33 /var/www/vendor/illuminate/console/Command.php(167):symfony \ Component \ Console \ Command \ Command-&gt; run(Object(Symfony \ Component \ Console \ Input \ ArgvInput),Object (照亮\控制台\ OutputStyle))

34 /var/www/vendor/symfony/console/Application.php(888):Illuminate \ Console \ Command-&gt; run(对象(Symfony \ Component \ Console \ Input \ ArgvInput),Object(Symfony \ Component) \控制台\输出\ ConsoleOutput))

35 /var/www/vendor/symfony/console/Application.php(224):symfony \ Component \ Console \ Application-&gt; 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-&gt; doRun(对象(Symfony \ Component \ Console \ Input \ ArgvInput),Object(Symfony) \组件\控制台\输出\ ConsoleOutput))

37 /var/www/vendor/laravel/lumen-framework/src/Console/Kernel.php(84):Symfony \ Component \ Console \ Application-&gt;运行(对象(Symfony \ Component \ Console \ Input \)对象(Symfony \ Component \ Console \ Output \ ConsoleOutput))

38 / var / www / artisan(35):Laravel \ Lumen \ Console \ Kernel-&gt;句柄(对象(Symfony \ Component \ Console \ Input \ ArgvInput),对象(Symfony \ Component \ Console \ Output \ ConsoleOutput ))

39 {main}

这很奇怪,因为它不应该尝试创建Pusher实例。

我尝试过使用composer dump-autoload,composer clear-cache,php artisan clear-compiled ......

这很有趣,因为如果我尝试这个代码并转储实例,我会得到一个配置良好的BroadcastManager:

$broadcastManager = (new BroadcastManager(app()))->connection();

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

不要告诉你的消息后发生了什么,试试看

composer require pusher/pusher-php-server --no-scripts

php artisan clear-compiled

编辑“vendor / laravel / framework / src / illuminate / Broadcasting / BroadcastManager.php”中的行

  

“使用Pusher;” “使用Pusher \ Pusher;”

在config / app.php中

将此行添加到别名

  

'Pusher'=&gt;推动器\推杆::类,