WebPush gmp 扩展未加载,但需要使用 payload 发送推送通知。您可以在 php.ini 中修复此问题

Mud*_*sir 5 php notifications push-notification laravel web-push

我正在使用 webpush 处理通知。我使用链接来实现通知网络推送。我正在搜索并应用上周的每个解决方案,但同样的问题我安装了 gmp 并在 xampp/etc/php.ini 中添加

extension = mcrypt.so
Run Code Online (Sandbox Code Playgroud)

这是我的代码

class InvoicePaid extends Notification implements ShouldQueue
{
    use Queueable;
    public $title, $body;
    public function __construct($title, $body)
    {
        //
        $this->title = $title;
        $this->body = $body;
    }
    public function via($notifiable)
    {
        return [WebPushChannel::class];
    }

    public function toWebPush($notifiable, $notification)
    {
        $time = \Carbon\Carbon::now();
        return WebPushMessage::create()
            // ->id($notification->id)
            ->title($this->title)
            ->icon(url('/push.png'))
            ->body($this->body);
        //->action('View account', 'view_account');
    }
}
Run Code Online (Sandbox Code Playgroud)

我的路线是

Route::post('/send-notification/{id}', function($id, Request $request){
    $user = \App\User::findOrFail($id);
    $user->notify(new \App\Notifications\GenericNotification($request->title, $request->body));
    return response()->json([
        'success' => true
    ]);
});
Run Code Online (Sandbox Code Playgroud)

但是当我发送通知时,我收到了这个错误,请 在此处输入图片描述

这是gmp安装的图片

myc*_*hel 2

尝试转到您的xampp/php/ext文件夹

  • 检查是否php_gmp.dll存在

    • 打开xampp/php/php.ini

      搜索php_gmp并确保它像extension=php_gmp.dll而不是;extension=php_gmp.dll

  • 别的

    • 下载php_gmp.dll到该文件夹​​并重试该过程

您不应该再次遇到 gmp 问题。