【问题标题】:PHP Error with array_merge in Pusher Second param is nullPusher 中的 array_merge 的 PHP 错误第二个参数为空
【发布时间】:2021-03-04 15:29:29
【问题描述】:

我正在尝试在 Laravel 中发送推送通知。我正在使用 pusher,但出现错误。

route.web

Route::get('push', function () {
    event(new App\Events\MessageToProveedor("Welcome"));
    return "Event has been sent!";
})->name('push');

MessageToProveedor 的文件

public $username;

public $message;
/**
 * Create a new event instance.
 *
 * @return void
 */
public function __construct($username)
{
    $this->username = $username;
    $this->message  = "liked your status";
}

/**
 * Get the channels the event should broadcast on.
 *
 * @return \Illuminate\Broadcasting\Channel|array
 */
public function broadcastOn()
{
    //channel
    return ['my-channel'];
}
public function broadcastAs()
{
    //event
    return 'my-event';
}

当我执行 de route /push 在 Pusher.php 插件中返回错误。

ErrorException array_merge(): Argument #2 is not an array

失败线 $all_params = array_merge($post_params,$params);

$params 为空

【问题讨论】:

    标签: laravel-6 pusher php-7.2


    【解决方案1】:

    你使用的是 Laravel v8.29.0 吗?这应该在该版本中得到解决。

    【讨论】:

    • 我正在使用 laravel v6.18.35
    • 您要么需要升级到指定的版本,要么降级 pusher-http-php (composer require pusher/pusher-php-server ^4.1) 的版本
    • 非常感谢,它适用于composer require pusher/pusher-php-server ^4.1
    猜你喜欢
    • 1970-01-01
    • 2014-06-08
    • 1970-01-01
    • 2021-05-31
    • 1970-01-01
    • 2023-03-27
    • 1970-01-01
    • 2017-07-09
    • 1970-01-01
    相关资源
    最近更新 更多