0
我想要做一些事情来运行使用自定义控制台命令发送laravel事件的测试。使用控制台命令发送广播事件到推送服务器
Artisan::command('event:send', function() {
event(new \MarketPlex\Events\ClientAction([ 'id' => 4, 'name' => 'MyEvent' ]));
$this->comment(Inspiring::quote());
})->describe('throws an event');
我的事件,
class ClientAction implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
/**
* The name of the queue on which to place the event.
*
* @var string
*/
public $broadcastQueue = 'client-action';
/**
* Information about the request created by user action (Must be public, otherwise laravel can't serialize).
*
* @var string
*/
public $request;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct(array $request)
{
//
$this->request = $request;
}
}
它不发送任何内容推服务器。我检查了所有的钥匙。
php artisan event:send
〜2.0。但如果我使用Pusher的trigger(),它会将消息发送到服务器。但如果我使用event()辅助方法,它不会发送。 – wOwhOw
我正在运行laravel 5.4并使用Pusher服务器〜2.6。还是一样。 – wOwhOw
嗨,没有看到所有的代码很难帮助 - 所以我会推荐阅读本教程。如果你不能得到这个工作,让我知道。 https://blog.pusher.com/writing-realtime-apps-with-laravel-5-and-pusher/ – kn100