PHPackages                             lukyrys/gcm - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. lukyrys/gcm

AbandonedLibrary[HTTP &amp; Networking](/categories/http)

lukyrys/gcm
===========

Google Cloud Messaging PHP library. Sender for sending Messages over HTTP amd Deamon for sending and recieving messages over XMPP (CCS).

011PHP

Since Feb 23Pushed 8y ago1 watchersCompare

[ Source](https://github.com/lukyrys/Gcm)[ Packagist](https://packagist.org/packages/lukyrys/gcm)[ RSS](/packages/lukyrys-gcm/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

PHP Google Cloud Messiging
==========================

[](#php-google-cloud-messiging)

Google Cloud Messaging PHP library. Gcm\\Http\\Sender for sending Messages over HTTP and Gcm\\Xmpp\\Daemon for sending and recieving messages over XMPP (CCS).

Dependencies
------------

[](#dependencies)

- Nette/Utils ~2.2.0
- JAXL 3.0.0

Install
-------

[](#install)

Best way is [Composer](http://getcomposer.org/):

```
$ composer require petrsladek/gcm:dev-master
```

Usage
-----

[](#usage)

### Http Sender

[](#http-sender)

```
use Gcm\Message;
use Gcm\Http\Sender;

$message = new Message("DEVICE_GCM_ID", ['foo'=>'bar', 'baz'=>[1,2,3]], "collapse-key-1");
$message->addTo("ANOTHER_DEVICE_GCM_ID");
$message->timeToLive(3600); // TTL 1 hour

$gcm = new Sender("YOUR_API_KEY");
$response = $gcm->send($message);

var_dump($response);
```

### XMPP Daemon recieving message

[](#xmpp-daemon-recieving-message)

```
use Gcm\Xmpp\Daemon;

$daemon = new Daemon("SENDER_ID", "API_KEY", $testMode = false);;

$daemon->onReady[] = function(Daemon $daemon) {
    print "Ready / Auth success. Waiting for Messages";
};
$daemon->onAuthFailure[] = function(Daemon $daemon, $reason) {
    print "Auth failure (reason $reason)";
};
$daemon->onStop[] = function(Daemon $daemon) {
    print 'Daemon has stopped by $daemon->stop()';
};
$daemon->onDisconnect[] = function(Daemon $daemon) {
    print "Daemon has been disconected";
};
$daemon->onMessage[] = function(Daemon $daemon, \Gcm\RecievedMessage $message) {
    print "Recieved message from GCM";
    print_r($message);
};

$daemon->run(); // running until call $daemon->stop() or kill process;
```

### XMPP Daemon sending messages

[](#xmpp-daemon-sending-messages)

```
use Gcm\Xmpp\Daemon;
use Gcm\Message;

$daemon = new Daemon("SENDER_ID", "API_KEY", $testMode = false);

$daemon->onReady[] = function(Daemon $daemon) {
    print "Ready / Auth success. Waiting for Messages";

    // We send 5 messages to device
    foreach([1,2,3,4,5] as $i) {
      $message = new Message("DEVICE_GCM_ID", ['text'=>"$i.message from server"],  "collapse-key-$i");
      $daemon->send($message);
    }
};
$daemon->onAuthFailure[] = function(Daemon $daemon, $reason) {
    print "Auth failure (reason $reason)";
};
$daemon->onStop[] = function(Daemon $daemon) {
    print 'Daemon has stopped by $daemon->stop()';
};
$daemon->onDisconnect[] = function(Daemon $daemon) {
    print "Daemon has been disconected";
};
$daemon->onMessage[] = function(Daemon $daemon, \Gcm\RecievedMessage $message) {
    print "Recieved message from GCM";
    print_r($message);
};
$daemon->onAllSent[] = function(Daemon $daemon, $countMessages) {
    print "Has been sent all of $countMessages";
    // On all of 5 messages has been sent and confirmed from server
    $deamom->stop(); // We stopped listeng
};

$daemon->run(); // Start sending messaging
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/01e4841749ee2b4cf7211d784b093bf67523ed6489c6931401211b130df13884?d=identicon)[lukyrys](/maintainers/lukyrys)

---

Top Contributors

[![PetrSladek](https://avatars.githubusercontent.com/u/9083002?v=4)](https://github.com/PetrSladek "PetrSladek (10 commits)")[![lukyrys](https://avatars.githubusercontent.com/u/2318346?v=4)](https://github.com/lukyrys "lukyrys (3 commits)")

### Embed Badge

![Health badge](/badges/lukyrys-gcm/health.svg)

```
[![Health](https://phpackages.com/badges/lukyrys-gcm/health.svg)](https://phpackages.com/packages/lukyrys-gcm)
```

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
