6

I am working on notification using webpush. i used this link to implement notificaton web push.I am searching and applying every solution from last week but same problem I installed gmp and i added in xampp/etc/php.ini

extension = mcrypt.so

This is my code

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

My route is

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

But when i send notification i got this error

enter image description here

This is picture of gmp installation

enter image description here

Dan Bonachea
  • 2,408
  • 5
  • 16
  • 31
Mudassir
  • 69
  • 1
  • 8
  • Which version of PHP are you using? – darthaditya Nov 11 '17 at 08:16
  • 1
    make sure you have php-gmp installed and add this line to your php.ini: `extension=php_gmp.so` – darthaditya Nov 11 '17 at 08:17
  • kindly i installed php-gmp and also add line in php.ini .kindly tell me how cam i make sure i installed gmp? – Mudassir Nov 11 '17 at 10:19
  • 1
    restart your server. then create a file called `index.php` or `whateveryouwant.php` in your server root directory. Paste this code into that file: ``. Then navigate to `http://localhost/index.php` or `http://localhost/whateveryouwant.php` in your browser to check your php configuration settings. If you find `gmp` there, then it's installed. – darthaditya Nov 11 '17 at 10:48
  • GNU GMP support Stanislav Malyshev this is info about gmp that i got after calling phpinfo()f – Mudassir Nov 11 '17 at 11:44
  • Okay. so that means your code should be working now. Are you still seeing an error? – darthaditya Nov 11 '17 at 15:03
  • Yes i am still getting same error . i am too much worried. – Mudassir Nov 11 '17 at 18:18
  • See if [this](https://serverfault.com/questions/429585/how-to-install-enable-gmp-math-functions-for-php-on-ubuntu) and [this for xampp on windows](https://stackoverflow.com/questions/44448409/xampp-windows-php-gmp-functions) helps you. – darthaditya Nov 12 '17 at 12:41
  • but i have macbook – Mudassir Nov 12 '17 at 13:50
  • why would you then use an xampp? Try using Homestead for development, it has all extensions and other commonly used things: https://laravel.com/docs/5.7/homestead – t1gor Oct 15 '18 at 13:39
  • @Mudassir Did you find the solution to this issue? I'm having the same issue and couldn't solve it at all. I researched everywhere but didn't get the solution. – KCP Oct 26 '18 at 16:10

2 Answers2

3

Ubuntu 18.04, PHP 7.4. Solved by following commands:

  1. sudo apt install php7.4-gmp
  2. sudo service php7.4-fpm restart
Rus Skazkin
  • 161
  • 2
  • 3
2

Try to go to your xampp/php/ext folder

  • check if php_gmp.dll exists

    • open xampp/php/php.ini

      search for php_gmp and make sure it's like extension=php_gmp.dll instead of ;extension=php_gmp.dll

  • else

    • download php_gmp.dll to the folder and try the procedure again

You should not have gmp issue again.

barbsan
  • 3,418
  • 11
  • 21
  • 28
myckhel
  • 800
  • 3
  • 15
  • 29