{"id":15905725,"url":"https://github.com/lkaybob/php-fcm-v1","last_synced_at":"2025-09-23T01:30:57.679Z","repository":{"id":62518358,"uuid":"125881367","full_name":"lkaybob/php-fcm-v1","owner":"lkaybob","description":"Implementation of Firebase Cloud Messaging HTTP v1 API in PHP","archived":false,"fork":false,"pushed_at":"2024-07-12T10:25:38.000Z","size":60,"stargazers_count":16,"open_issues_count":11,"forks_count":19,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-11T04:49:01.647Z","etag":null,"topics":["fcm","firebase","notifications","php","php-fcm"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/lkaybob/php-fcm-v1","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lkaybob.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-19T15:40:01.000Z","updated_at":"2024-11-17T11:29:15.000Z","dependencies_parsed_at":"2024-10-28T09:13:57.568Z","dependency_job_id":"bec9bb4e-4c96-479d-b077-00481066b42e","html_url":"https://github.com/lkaybob/php-fcm-v1","commit_stats":{"total_commits":34,"total_committers":4,"mean_commits":8.5,"dds":"0.17647058823529416","last_synced_commit":"c015baa6382b8a1fda29ac40683cf4bbc70fc147"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/lkaybob/php-fcm-v1","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lkaybob%2Fphp-fcm-v1","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lkaybob%2Fphp-fcm-v1/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lkaybob%2Fphp-fcm-v1/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lkaybob%2Fphp-fcm-v1/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lkaybob","download_url":"https://codeload.github.com/lkaybob/php-fcm-v1/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lkaybob%2Fphp-fcm-v1/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276502707,"owners_count":25653732,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-22T02:00:08.972Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fcm","firebase","notifications","php","php-fcm"],"created_at":"2024-10-06T13:07:26.489Z","updated_at":"2025-09-23T01:30:57.402Z","avatar_url":"https://github.com/lkaybob.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# php-fcm-v1\n[![Build Status](https://github.com/lkaybob/php-fcm-v1/actions/workflows/main.yml/badge.svg)](https://github.com/lkaybob/php-fcm-v1/actions)\n[![codecov](https://codecov.io/gh/lkaybob/php-fcm-v1/branch/master/graph/badge.svg)](https://codecov.io/gh/lkaybob/php-fcm-v1)\n[![Latest Stable Version](https://poser.pugx.org/lkaybob/php-fcm-v1/v/stable)](https://packagist.org/packages/lkaybob/php-fcm-v1)\n[![Total Downloads](https://poser.pugx.org/lkaybob/php-fcm-v1/downloads)](https://packagist.org/packages/lkaybob/php-fcm-v1)\n[![License](https://poser.pugx.org/lkaybob/php-fcm-v1/license)](https://packagist.org/packages/lkaybob/php-fcm-v1)\n\nphp-fcm-v1 is an PHP implementation of [FCM](https://firebase.google.com/docs/cloud-messaging) HTTP v1 API\n\n### What is different compared to others FCM Libraries?\nMost of other libraries are implementation of FCM's [Legacy HTTP Server Protocol](https://firebase.google.com/docs/cloud-messaging/http-server-ref). It requires a server key from Firebase console (which means you have to copy and paste in your code) ([Docs](https://firebase.google.com/docs/cloud-messaging/auth-server#authorize_legacy_protocol_send_requests))\n\nHTTP v1 API, in contrast, leverages OAuth2 security model. You need to get an access token (which is valid for about an hour) in order to request sending notification with service account's private key file. Although \n(See the blog [post](https://firebase.googleblog.com/2017/11/whats-new-with-fcm-customizing-messages.html) about HTTP v1 API)\n\n### References\n* [google/node-gtoken](https://github.com/google/node-gtoken)\n* [google/google-auth-library-nodejs](https://github.com/google/google-auth-library-nodejs) \n  : Above two libraries let me understand how HTTP v1 API works in FCM\n* [guzzlehttp/guzzle](https://github.com/guzzle/guzzle) : GuzzleHttp let this library to PSR7 compatible\n* [Paragraph1/php-fcm](https://github.com/Paragraph1/php-fcm) : Inspired me how FCM libraries are used in Legacy HTTP Protocol\n\n### How to use\n\n* Install the library with composer\n\n  ```\n  composer require lkaybob/php-fcm-v1\n  ```\n****\n* Import the library with *autoload.php*\n\n  ```php\n  \u003c?php\n  require_once __DIR__ . '/vendor/autoload.php';\n\n  use phpFCMv1\\Client;\n  use phpFCMv1\\Notification;\n  use phpFCMv1\\Recipient;\n  ```\n\n* Create Necessary class instances, Client, Recipient, Notification/Data\n\n  ```php\n  // Client instance should be created with path to service account key file\n  $client = new Client('service_account.json');\n  $recipient = new Recipient();\n  // Either Notification or Data (or both) instance should be created\n  $notification = new Notification();\n  ```\n\n* Setup each instances with necessary information\n\n  ```php\n  // Recipient could accept individual device token,\n  // the name of topic, and conditional statement\n  $recipient -\u003e setSingleREcipient('DEVICE_TOKEN');\n  // Setup Notificaition title and body\n  $notification -\u003e setNotification('NOTIFICATION_TITLE', 'NOTIFICATION_BODY');\n  // Build FCM request payload\n  $client -\u003e build($recipient, $notification);\n  ```\n\n* Fire in the FCM Server!\n\n  ```php\n  $result = $client -\u003e fire();\n  // You can check the result\n  // If successful, true will be returned\n  // If not, error message will be returned\n  echo $result;\n  ```\n\n### Further Example\n\n* Full Simple Example\n\n  ```php\n  \u003c?php\n  require_once __DIR__ . '/vendor/autoload.php';\n\n  use phpFCMv1\\Client;\n  use phpFCMv1\\Notification;\n  use phpFCMv1\\Recipient;\n\n  $client = new Client('service_account.json');\n  $recipient = new Recipient();\n  $notification = new Notification();\n\n  $recipient -\u003e setSingleRecipient('DEVICE_TOKEN');\n  $notification -\u003e setNotification('NOTIFICATION_TITILE', 'NOTIFICATION_BODY');\n  $client -\u003e build($recipient, $notification);\n  $client -\u003e fire();\n  ```\n\n* Using with *PRIOIRTY* option (for both Android \u0026 iOS)\n\n  ```php\n  \u003c?php\n  require_once __DIR__ . '/vendor/autoload.php';\n\n  use phpFCMv1\\Client;\n  use phpFCMv1\\Config;\n  use phpFCMv1\\Notification;\n  use phpFCMv1\\Recipient;\n\n  $client = new Client('service_account.json');\n  $recipient = new Recipient();\n  $notification = new Notification();\n  $config = new Config();\n\n  $recipient -\u003e setSingleRecipient('DEVICE_TOKEN');\n  $notification -\u003e setNotification('NOTIFICATION_TITLE', 'NOTIFICATION_BODY');\n  $config -\u003e setPriority(Config::PRIORITY_HIGH);\n  $client -\u003e build($recipient, $notification, null, $config);\n  $result = $client -\u003e fire();\n  ```\n\n* For independent platform (either Android or iOS)\n\n  ```\n  // Option Instance for Android\n  // Use phpFCMv1\\AndroidConfig Class\n  $androidConfig = new Config\\AndroidConfig();\n  $androidConfig -\u003e setPriority(Config\\AndroidConfig::PRIORITY_HIGH);\n  $client -\u003e build($recipient, $notification, null, $androidConfig);\n  \n  // Option Instance for iOS (which is APNs header)\n  // Use phpFCMv1\\APNsCOnfig Class\n  $apnsConfig = new APNsConfig();\n  $apnsConfig -\u003e setPriority(APNsConfig::PRIORITY_HIGH);\n  $client -\u003e build($recipient, $notification, null, $apnsConfig);\n  ```\n\n\n\n### Future Works\n\n- [ ] Implement simultaneous send (Currently supports single recipient or topic one at a time)\n- [ ] Setup Read the Docs\n- [x] Add CI Test\n- [x] Add CodeCov Badge\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flkaybob%2Fphp-fcm-v1","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flkaybob%2Fphp-fcm-v1","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flkaybob%2Fphp-fcm-v1/lists"}