昨天我从github安装了laravel / talk应用程序。我的意思是那个laravel谈话的例子。我在这里将代码更改为我的推送应用程序等,并且我在broadcast.php中将false更改为true。
但我得到错误:
Broadcast.php第62行中的ErrorException:array_merge():参数#1是 不是数组
你知道为什么吗?
包装:https://github.com/nahid/talk-example
class Broadcast
{
use DispatchesJobs;
/*
* Constant for talk config prefix
*
* @const string
* */
const CONFIG_PATH = 'talk';
/*
* Set all configs from talk configurations
*
* @var array
* */
protected $config;
/*
* Pusher instance
*
* @var object
* */
public $pusher;
/**
* Connect pusher and get all credentials from config.
*
* @param \Illuminate\Contracts\Config\Repository $config
*/
public function __construct(Repository $config)
{
$this->config = $config;
$this->pusher = $this->connectPusher();
}
/**
* Make pusher connection.
*
* @param array $options
*
* @return object | bool
*/
protected function connectPusher($options = [])
{
if ($this->getConfig('broadcast.enable')) {
$appId = $this->getConfig('broadcast.pusher.app_id');
$appKey = $this->getConfig('broadcast.pusher.app_key');
$appSecret = $this->getConfig('broadcast.pusher.app_secret');
$appOptions = $this->getConfig('broadcast.pusher.options');
$newOptions = array_merge($appOptions, $options); // line 62
$pusher = new Pusher($appKey, $appSecret, $appId, $newOptions);
return $pusher;
}
return false;
}
/**
* Dispatch the job to the queue.
*
* @param \Nahid\Talk\Messages\Message $message
*/
public function transmission(Message $message)
{
if (!$this->pusher) {
return false;
}
$sender = $message->sender->toArray();
$messageArray = $message->toArray();
$messageArray['sender'] = $sender;
$this->dispatch(new Webcast($messageArray));
}
/**
* get specific config from talk configurations.
*
* @param string
*
* @return string|array|int
*/
public function getConfig($name)
{
return $this->config->get(self::CONFIG_PATH.'.'.$name);
}
}