Search code examples
phpweb-push

Web Push PHP library Error


I am trying to put push messages on my website with the PHP Push Web library.

Registration when accepting notifications works well. Save and delete if you have accepted or canceled the subscription to notifications.

The error appears when you try to send a message : First I installed GMP, it is well installed, but now it shows a different error with Vendor files.

Catchable fatal error: Argument 2 passed to Mdanter\Ecc\Primitives\CurveParameters::__construct() must be an instance of GMP, resource given
    called in /home/ubuntu/workspace/php_push_demo/vendor/mdanter/ecc/src/Curves/NistCurve.php on line 136 
    and defined in /home/ubuntu/workspace/php_push_demo/vendor/mdanter/ecc/src/Primitives/CurveParameters.php on line 39

Call Stack:
    0.0006     238472   1. {main}() /home/ubuntu/workspace/php_push_demo/send_push_notification.php:0
    0.0118     429552   2. Minishlink\WebPush\WebPush->sendNotification() /home/ubuntu/workspace/php_push_demo/send_push_notification.php:55
    0.0120     435776   3. Minishlink\WebPush\WebPush->flush() /home/ubuntu/workspace/php_push_demo/vendor/minishlink/web-push/src/WebPush.php:115
    0.0120     436896   4. Minishlink\WebPush\WebPush->prepare() /home/ubuntu/workspace/php_push_demo/vendor/minishlink/web-push/src/WebPush.php:156
    0.0122     438872   5. Minishlink\WebPush\VAPID::getVapidHeaders() /home/ubuntu/workspace/php_push_demo/vendor/minishlink/web-push/src/WebPush.php:258
    0.0136     472216   6. Mdanter\Ecc\Curves\NistCurve->generator256() /home/ubuntu/workspace/php_push_demo/vendor/minishlink/web-push/src/VAPID.php:123
    0.0136     472352   7. Mdanter\Ecc\Curves\NistCurve->curve256() /home/ubuntu/workspace/php_push_demo/vendor/mdanter/ecc/src/Curves/NistCurve.php:149
    0.0138     477328   8. Mdanter\Ecc\Primitives\CurveParameters->__construct() /home/ubuntu/workspace/php_push_demo/vendor/mdanter/ecc/src/Curves/NistCurve.php:136

Solution

  • To fix it I had to update my PHP 7.0 to 7.1 version. After that I haven't had any more problems.

    You can get more information about the library here