Describe the issue you are experiencing
Hello all, I encountered an issue with Cloud Messaging.
$messaging->send($message); --> This function result in the following error:
An uncaught Exception was encountered
Type: Kreait\Firebase\Exception\Messaging\MessagingError
Message: syntax error, unexpected '|', expecting variable (T_VARIABLE)
Filename: ../vendor/kreait/firebase-php/src/Firebase/Exception/MessagingApiExceptionConverter.php
Line Number: 56
I used the following codes:
use Kreait\Firebase\Factory;
use Kreait\Firebase\Messaging\CloudMessage;
use Kreait\Firebase\Messaging\Notification;
$factory = (new Factory)->withServiceAccount('path to sdk json');
$messaging = $factory->createMessaging();
$message = CloudMessage::withTarget('token', 'my device token')
->withNotification(Notification::create('Title', 'Body'));
$messaging->send($message);
Error occur when it reach this function --> $messaging->send($message);
I have also tried with kreait/firebase v6. Same error occur.
Environment:
PHP 7.4.3.
kreait/firebase-php 5.26.1
Framework Codeigniter 3.1.11 with composer autoload.
Thanks for the help.
Installed packages
chriskacerguis/codeigniter-restserver 3.1.2 CI Rest Server
fig/http-message-util 1.1.5 Utility classes and constants...
firebase/php-jwt v5.5.1 A simple library to encode an...
google/auth v1.18.0 Google Auth Library for PHP
google/cloud-core v1.43.2 Google Cloud PHP shared depen...
google/cloud-storage v1.26.0 Cloud Storage Client for PHP
google/crc32 v0.1.0 Various CRC32 implementations
guzzlehttp/guzzle 7.4.1 Guzzle is a PHP HTTP client l...
guzzlehttp/promises 1.5.1 Guzzle promises library
guzzlehttp/psr7 2.1.0 PSR-7 message implementation ...
kreait/clock 1.1.0 A PHP 7.0 compatible clock ab...
kreait/firebase-php 5.26.1 Firebase Admin SDK
kreait/firebase-tokens 1.16.1 A library to work with Fireba...
lcobucci/clock 2.1.0 Yet another clock abstraction
lcobucci/jwt 4.1.5 A simple library to work with...
monolog/monolog 2.3.5 Sends your logs to files, soc...
mtdowling/jmespath.php 2.6.1 Declaratively specify how to ...
psr/cache 2.0.0 Common interface for caching ...
psr/http-client 1.0.1 Common interface for HTTP cli...
psr/http-factory 1.0.1 Common interfaces for PSR-7 H...
psr/http-message 1.0.1 Common interface for HTTP mes...
psr/log 3.0.0 Common interface for logging ...
psr/simple-cache 1.0.1 Common interfaces for simple ...
ralouphie/getallheaders 3.0.3 A polyfill for getallheaders.
riverline/multipart-parser 2.0.9 One class library to parse mu...
rize/uri-template 0.3.4 PHP URI Template (RFC 6570) s...
symfony/deprecation-contracts v3.0.0 A generic function and conven...
symfony/polyfill-mbstring v1.24.0 Symfony polyfill for the Mbst...
symfony/polyfill-php80 v1.24.0 Symfony polyfill backporting ...
symfony/polyfill-php81 v1.24.0 Symfony polyfill backporting ..
PHP version and extensions
composer-plugin-api 1.1.0 The Composer Plugin API
ext-bz2 7.4.3 The bz2 PHP extension
ext-calendar 7.4.3 The calendar PHP extension
ext-ctype 7.4.3 The ctype PHP extension
ext-curl 7.4.3 The curl PHP extension
ext-date 7.4.3 The date PHP extension
ext-dom 20031129 The dom PHP extension
ext-exif 7.4.3 The exif PHP extension
ext-FFI 7.4.3 The FFI PHP extension
ext-fileinfo 7.4.3 The fileinfo PHP extension
ext-filter 7.4.3 The filter PHP extension
ext-ftp 7.4.3 The ftp PHP extension
ext-gd 7.4.3 The gd PHP extension
ext-gettext 7.4.3 The gettext PHP extension
ext-hash 7.4.3 The hash PHP extension
ext-iconv 7.4.3 The iconv PHP extension
ext-json 7.4.3 The json PHP extension
ext-libxml 7.4.3 The libxml PHP extension
ext-mbstring 7.4.3 The mbstring PHP extension
ext-mysqli 7.4.3 The mysqli PHP extension
ext-mysqlnd 0 The mysqlnd PHP extension (actual version: mys...
ext-openssl 7.4.3 The openssl PHP extension
ext-pcntl 7.4.3 The pcntl PHP extension
ext-pcre 7.4.3 The pcre PHP extension
ext-PDO 7.4.3 The PDO PHP extension
ext-pdo_mysql 7.4.3 The pdo_mysql PHP extension
ext-Phar 7.4.3 The Phar PHP extension
ext-posix 7.4.3 The posix PHP extension
ext-readline 7.4.3 The readline PHP extension
ext-Reflection 7.4.3 The Reflection PHP extension
ext-session 7.4.3 The session PHP extension
ext-shmop 7.4.3 The shmop PHP extension
ext-SimpleXML 7.4.3 The SimpleXML PHP extension
ext-sockets 7.4.3 The sockets PHP extension
ext-sodium 7.4.3 The sodium PHP extension
ext-SPL 7.4.3 The SPL PHP extension
ext-sysvmsg 7.4.3 The sysvmsg PHP extension
ext-sysvsem 7.4.3 The sysvsem PHP extension
ext-sysvshm 7.4.3 The sysvshm PHP extension
ext-tokenizer 7.4.3 The tokenizer PHP extension
ext-xml 7.4.3 The xml PHP extension
ext-xmlreader 7.4.3 The xmlreader PHP extension
ext-xmlwriter 7.4.3 The xmlwriter PHP extension
ext-xsl 7.4.3 The xsl PHP extension
ext-Zend-OPcache 7.4.3 The Zend OPcache PHP extension
ext-zip 1.15.6 The zip PHP extension
ext-zlib 7.4.3 The zlib PHP extension
lib-curl 7.68.0 The curl PHP library
lib-iconv 2.31 The iconv PHP library
lib-libxml 2.9.10 The libxml PHP library
lib-openssl 1.1.1.6 OpenSSL 1.1.1f 31 Mar 2020
lib-pcre 10.34 The pcre PHP library
lib-xsl 1.1.34 The xsl PHP library
php 7.4.3 The PHP interpreter
php-64bit 7.4.3 The PHP interpreter, 64bit
php-ipv6 7.4.3 The PHP interpreter, with IPv6 support
On which operating system(s) does the issue occur?
- [X] Linux
- [ ] MacOS
- [ ] Windows
Steps to reproduce the issue.
use Kreait\Firebase\Factory;
use Kreait\Firebase\Messaging\CloudMessage;
use Kreait\Firebase\Messaging\Notification;
$factory = (new Factory)->withServiceAccount('path to sdk json');
$messaging = $factory->createMessaging();
$message = CloudMessage::withTarget('token', 'my device token')
->withNotification(Notification::create('Title', 'Body'));
$messaging->send($message);
Error message/Stack trace
An uncaught Exception was encountered
<p>Type: Kreait\Firebase\Exception\Messaging\MessagingError</p>
<p>Message: syntax error, unexpected '|', expecting variable (T_VARIABLE)</p>
<p>Filename:
/vendor/kreait/firebase-php/src/Firebase/Exception/MessagingApiExceptionConverter.php
</p>
<p>Line Number: 56</p>
<p>Backtrace:</p>
<p style="margin-left:10px">
File:
/vendor/kreait/firebase-php/src/Firebase/Messaging/ApiClient.php<br />
Line: 44<br />
Function: convertException </p>
<p style="margin-left:10px">
/vendor/kreait/firebase-php/src/Firebase/Messaging.php<br />
Line: 54<br />
Function: send </p>
Additional information
No response
bug 🐞