PHPackages                             wyrihaximus/ratchet-commands - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. wyrihaximus/ratchet-commands

AbandonedArchivedCakephp-plugin[Utility &amp; Helpers](/categories/utility)

wyrihaximus/ratchet-commands
============================

Brings 2 way communication to wyrihaximus/ratchet.

0.1.0(11y ago)061.5k[5 issues](https://github.com/WyriHaximus/RatchetCommands/issues)[2 PRs](https://github.com/WyriHaximus/RatchetCommands/pulls)2MITPHPPHP &gt;=5.4.0

Since Jan 22Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/WyriHaximus/RatchetCommands)[ Packagist](https://packagist.org/packages/wyrihaximus/ratchet-commands)[ Docs](http://github.com/WyriHaximus/RatchetCommands)[ RSS](/packages/wyrihaximus-ratchet-commands/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (3)Versions (4)Used By (2)

RatchetCommands
===============

[](#ratchetcommands)

[![Build Status](https://camo.githubusercontent.com/0f89c9f82c46333ab797cb77c89f5f2f593f30da1ddac2d7a76de37d077a1ed1/68747470733a2f2f7472617669732d63692e6f72672f57797269486178696d75732f52617463686574436f6d6d616e64732e706e67)](https://travis-ci.org/WyriHaximus/RatchetCommands)[![Latest Stable Version](https://camo.githubusercontent.com/709fad9f806f9dbee918d24b86079b28d3488ff04929c40ce1dd7b0cc838cf42/68747470733a2f2f706f7365722e707567782e6f72672f57797269486178696d75732f526174636865742d436f6d6d616e64732f762f737461626c652e706e67)](https://packagist.org/packages/WyriHaximus/Ratchet-Commands)[![Total Downloads](https://camo.githubusercontent.com/dad5202d6a55169cfc38c28971acf970279b1467740560ba1313365d78f62076/68747470733a2f2f706f7365722e707567782e6f72672f57797269486178696d75732f526174636865742d436f6d6d616e64732f646f776e6c6f6164732e706e67)](https://packagist.org/packages/WyriHaximus/Ratchet-Commands)[![Coverage Status](https://camo.githubusercontent.com/801c00818871c1c212a17066a22d725d607da3cf7e67933485519d3cc01ae48f/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f57797269486178696d75732f52617463686574436f6d6d616e64732f62616467652e706e67)](https://coveralls.io/r/WyriHaximus/RatchetCommands)[![Bitdeli Badge](https://camo.githubusercontent.com/d4589616793c0555a5ad4b2048bb36c0f8d0001497e271fb590f8a76549eff80/68747470733a2f2f64327765637a68766c38323376302e636c6f756466726f6e742e6e65742f57797269486178696d75732f72617463686574636f6d6d616e64732f7472656e642e706e67)](https://bitdeli.com/free "Bitdeli Badge")

RatchetCommands lets your application communicate messages to the Ratchet server instance.

Getting started
---------------

[](#getting-started)

#### 1. Requirements

[](#1-requirements)

This plugin depends on the following plugin and libraries and are pulled in by composer later on:

- [Ratchet](https://github.com/WyriHaximus/Ratchet)

#### 2. Composer

[](#2-composer)

Make sure you have [composer](http://getcomposer.org/) installed and configured with the autoloader registering during bootstrap as described [here](http://ceeram.github.io/blog/2013/02/22/using-composer-with-cakephp-2-dot-x/). Make sure you have a composer.json and add the following to your required section.

```
composer require wyrihaximus/ratchet-commands

```

#### 3. Setup the plugin

[](#3-setup-the-plugin)

Make sure you load `RatchetCommands` in your bootstrap and the `Ratchet` plugin is setup properly.

#### 4. Building a command

[](#4-building-a-command)

Filename: `Lib/MessageQueue/Command/BroadcastCommand.php`

```
class BroadcastCommand extends RatchetMessageQueueCommand {

	public function serialize() {
		return serialize(array(
			'data' => $this->data,
		));
	}

	public function unserialize($commandString) {
		$commandString = unserialize($commandString);
		$this->setData($commandString['data']);
	}

	public function setData($data) {
		$this->data = $data;
	}

	public function getData() {
		return $this->data;
	}

	// Send a broadcast on the channel `channel` with the data sent with the command
	// (This runs in the Ratchet instance.)
	public function execute($eventSubject) {
		$topics = $eventSubject->getTopics();
		if (isset($topics['channel'])) {
			$topics['channel']->broadcast($this->getData());
		}

		return true;
	}

	// Handle the response
	// (This runs in the application.)
	public function response($response) {
		if ($response) {
			// Handle success
		} else {
			// Handle failure
		}
	}
}
```

Besure to App::uses the command in your bootstrap so the Ratchet instance knows where to load it from.

#### 5. Sending the message

[](#5-sending-the-message)

```
App::uses('TransportProxy', 'RatchetCommands.Lib/MessageQueue/Transports');
$command = new BroadcastCommand();
$command->setData([
	'time' => time(),
]);
TransportProxy::instance()->queueMessage($command);
```

Plugin License
--------------

[](#plugin-license)

(The MIT License)

Copyright © 2012 - 2013 Cees-Jan Kiewiet

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance40

Moderate activity, may be stable

Popularity23

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98% 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4177d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/147145?v=4)[Cees-Jan Kiewiet](/maintainers/WyriHaximus)[@WyriHaximus](https://github.com/WyriHaximus)

---

Top Contributors

[![WyriHaximus](https://avatars.githubusercontent.com/u/147145?v=4)](https://github.com/WyriHaximus "WyriHaximus (50 commits)")[![bitdeli-chef](https://avatars.githubusercontent.com/u/3092978?v=4)](https://github.com/bitdeli-chef "bitdeli-chef (1 commits)")

---

Tags

hacktoberfestcakephp

### Embed Badge

![Health badge](/badges/wyrihaximus-ratchet-commands/health.svg)

```
[![Health](https://phpackages.com/badges/wyrihaximus-ratchet-commands/health.svg)](https://phpackages.com/packages/wyrihaximus-ratchet-commands)
```

###  Alternatives

[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.3k10](/packages/helsingborg-stad-municipio)[mautic/core

Mautic Open Source Distribution

9.8k2.6k9](/packages/mautic-core)[mediawiki/maps

Adds various mapping features to MediaWiki

78149.7k3](/packages/mediawiki-maps)[civicrm/civicrm-drupal-8

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

19246.3k2](/packages/civicrm-civicrm-drupal-8)[altis/core

Core module for Altis

19222.5k2](/packages/altis-core)[chronon/mobile_detect

A CakePHP plugin component for identifying mobile devices using the Mobile\_Detect project.

24252.6k1](/packages/chronon-mobile-detect)

PHPackages © 2026

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