PHPackages                             wyrihaximus/ratchet-model-push - 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-model-push

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

wyrihaximus/ratchet-model-push
==============================

Allows models to push data on write operations to wyrihaximus/ratchet.

0.1.0(11y ago)261.3k1[3 PRs](https://github.com/WyriHaximus/RatchetModelPush/pulls)MITPHP

Since Jan 22Pushed 8mo ago2 watchersCompare

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

READMEChangelog (1)Dependencies (3)Versions (5)Used By (0)

RatchetModelPush
================

[](#ratchetmodelpush)

[![Build Status](https://camo.githubusercontent.com/5c217c172b347cc593a7ed436b90bba9710e977c31a92c3e7feccfc45fca25be/68747470733a2f2f7472617669732d63692e6f72672f57797269486178696d75732f526174636865744d6f64656c507573682e706e67)](https://travis-ci.org/WyriHaximus/RatchetModelPush)[![Latest Stable Version](https://camo.githubusercontent.com/377607ba46f4e612dda3a3e2624b793f51376c638df025a2caa8a78f4f13d191/68747470733a2f2f706f7365722e707567782e6f72672f57797269486178696d75732f726174636865742d6d6f64656c2d707573682f762f737461626c652e706e67)](https://packagist.org/packages/WyriHaximus/ratchet-model-push)[![Total Downloads](https://camo.githubusercontent.com/5f97f987c7f3a6d017a070b345926d80670492328d79a80e908fe70776255821/68747470733a2f2f706f7365722e707567782e6f72672f77797269686178696d75732f726174636865742d6d6f64656c2d707573682f646f776e6c6f6164732e706e67)](https://packagist.org/packages/wyrihaximus/ratchet-model-push)[![Code Coverage](https://camo.githubusercontent.com/1b8654079f48b5ba7328f769bffde83beedcf53d80575f96539d5159ee3c7c10/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f57797269486178696d75732f526174636865744d6f64656c507573682f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/WyriHaximus/ratchet-model-push/?branch=master)[![License](https://camo.githubusercontent.com/40202e1faeb890e5231a3bce93adf3798d9e13690f80ab7d96949e9229d26685/68747470733a2f2f706f7365722e707567782e6f72672f77797269686178696d75732f726174636865742d6d6f64656c2d707573682f6c6963656e73652e706e67)](https://packagist.org/packages/wyrihaximus/ratchet-model-push)[![PHP 7 ready](https://camo.githubusercontent.com/76c4cd6258692e514af79386f12c5dcb934f2a5adec53f54b7e45c747aeb4845/687474703a2f2f7068703772656164792e74696d6573706c696e7465722e63682f57797269486178696d75732f526174636865744d6f64656c507573682f62616467652e737667)](https://travis-ci.org/WyriHaximus/RatchetModelPush)

Model Push for the [CakePHP Ratchet plugin](http://wyrihaximus.net/projects/cakephp/ratchet/).

What is Ratchet
---------------

[](#what-is-ratchet)

Ratchet for CakePHP brings [the Ratchet websocket](http://socketo.me/) server to CakePHP. Websockets allow you to utilize near-real-time communication between your application and it's visitors. For example notifying a page the associated record in the database has been updated using the [Pushable behaviour](http://wyrihaximus.net/projects/cakephp/ratchet/documentation/model-push.html).

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

[](#getting-started)

#### 1. Requirements

[](#1-requirements)

This plugin depends on the following plugins and their dependencies and are pulled in by composer later on:

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

#### 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-model-push

```

When you've set everything up, run `composer install`.

#### 3. Setup the plugin

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

Make sure you load `RatchetModelPush` and all the plugins it depends on and their dependecies in your bootstrap and set then up properly.

#### 4. Setting up the behavior

[](#4-setting-up-the-behavior)

The following code example attaches the Pushable behavior to the `WyriProject` model. The events do the following in order:

1. Fires on creating on a new record and binds to `WyriProject.created`.
2. Fires on updating any record and binds to `WyriProject.updated`.
3. Fires on any updating record and binds to `WyriProject.updated.{id}` where `{id}` is the `id` for that record. So if `id` is `1` it binds to `WyriProject.updated.1`.

The data is passed into the event as a 1 dimensional array.

```
