PHPackages                             blenderdeluxe/ortc-php - 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. [API Development](/categories/api)
4. /
5. blenderdeluxe/ortc-php

ActiveProject[API Development](/categories/api)

blenderdeluxe/ortc-php
======================

A PHP API wrapper for ORTC (Realtime pub/sub framework from RealTime.co)

1.5(8y ago)0331MITPHPPHP &gt;=5.4.0

Since Dec 11Pushed 8y ago1 watchersCompare

[ Source](https://github.com/blenderdeluxe/ortc-php)[ Packagist](https://packagist.org/packages/blenderdeluxe/ortc-php)[ RSS](/packages/blenderdeluxe-ortc-php/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (5)Dependencies (4)Versions (6)Used By (1)

ORTC-PHP (PHP API Client for Realtime.co)
=========================================

[](#ortc-php-php-api-client-for-realtimeco)

[![Build Status](https://camo.githubusercontent.com/7ab2fc111613ddbe86f10f353b35eb9aa81a2a13cdc62e7337e9990207323732/68747470733a2f2f7472617669732d63692e6f72672f6e696b617070732f6f7274632d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/nikapps/ortc-php)

[![Real-time Framework - ORTC](https://camo.githubusercontent.com/8a00281f6dbc4c851a952ee93accc1fed5ce385d712ee2065dc4b4cec385423d/68747470733a2f2f7777772e64726f70626f782e636f6d2f732f7a366279386a696e643973336d35762f7265616c74696d652e706e673f7261773d31)](https://camo.githubusercontent.com/8a00281f6dbc4c851a952ee93accc1fed5ce385d712ee2065dc4b4cec385423d/68747470733a2f2f7777772e64726f70626f782e636f6d2f732f7a366279386a696e643973336d35762f7265616c74696d652e706e673f7261773d31)

It's an unofficial client for [ORTC](http://framework.realtime.co/messaging) (Open Real-Time Connectivity, realtime &amp; cloud-based pub/sub framework from [realtime.co](http://www.realtime.co) for PHP 5.4+), but yet powerful, composer based and compatible with psr-1, psr-2 and psr-4.

Installation
------------

[](#installation)

Using composer, install this [package](https://packagist.org/packages/nikapps/ortc-php) by running this command:

```
composer require nikapps/ortc-php

```

Configuration
-------------

[](#configuration)

#### Get Application Key &amp; Private Key

[](#get-application-key--private-key)

First of all, you should register on realtime.co and get your api keys.

- Login/Register at
- Create new Subscription
- You can see your `Application Key` and `Private Key`
- If you want to use authentication, you should enable it in your panel.

#### Ortc Config

[](#ortc-config)

Before you can call any api call, you should set your credentials.

```
$ortcConfig = new \Nikapps\OrtcPhp\Configs\OrtcConfig();

$ortcConfig->setApplicationKey('YOUR_APPLICATION_KEY'); //you application key
$ortcConfig->setPrivateKey('YOUR_PRIVATE_KEY'); //Your private key
$ortcConfig->setVerifySsl(true); //verify ssl/tls certificate
```

#### Done!

[](#done)

Usage
-----

[](#usage)

#### Get Balancer URL (Manually)

[](#get-balancer-url-manually)

This package automatically get balancer url (best available server), but if you want fetch a new balancer url manually:

```
$ortc = new \Nikapps\OrtcPhp\Ortc($ortcConfig);

$balancerUrl = $ortc->getBalancerUrl();

echo 'Balancer Url: ' . $balancerUrl->getUrl();
```

#### Authentication

[](#authentication)

In order to authenticate a user:

- Create channel(s):

First, you should create your channels:

```
$channelOne = new \Nikapps\OrtcPhp\Models\Channel();
$channelOne->setName('CHANNEL_ONE_NAME');
$ChannelOne->setPermission(Channel::PERMISSION_WRITE);

$channelTwo = new \Nikapps\OrtcPhp\Models\Channel();
$channelTwo->setName('CHANNEL_TWO_NAME');
$channelTwo->setPermission(Channel::PERMISSION_READ);

$channels = [
	$channelOne,
	$channelTwo
];
```

- Authenticate:

Then authenticate the user:

```
$authToken = 'YOUR_AUTH_TOKEN'; //your authentication token

$authRequest = new \Nikapps\OrtcPhp\Models\Requests\AuthRequest();
$authRequest->setAuthToken($authToken);
$authRequest->setExpireTime(5 * 60); //token ttl (expiration time) in seconds
$authRequest->setPrivate(true); //Indicates whether the authentication token is private
$authRequest->setChannels($channels);

$ortc = new \Nikapps\OrtcPhp\Ortc($ortcConfig);
$ortc->authenticate($authRequest);
```

#### Send Message (Push)

[](#send-message-push)

In order to push a message to a channel:

```
$authToken = 'YOUR_AUTH_TOKEN'; //your authentication token

$sendMessageRequest = new \Nikapps\OrtcPhp\Models\Requests\SendMessageRequest();
$sendMessageRequest->setAuthToken($authToken);
$sendMessageRequest->setChannelName('CHANNEL_NAME');
$sendMessageRequest->setMessage('YOUR_MESSAGE');

$ortc = new \Nikapps\OrtcPhp\Ortc($ortcConfig);
$ortc->sendMessage($sendMessageRequest);
```

*If you using UTF-8 messages, it's better to use `base64_encode()`.*

Exceptions
----------

[](#exceptions)

- **OrtcException**

*Parent of other exceptions*

- **UnauthorizedException**

*When token is expired or credentials are invalid*

- **InvalidBalancerUrlException**

*When balancer url is invalid*

-You can get url by `getUrl()`

- **BatchRequestException**

*When at least one message response is failed*

-You can get all results by `getResults()`. It returns a `\GuzzleHttp\BatchResults` object.

- **NetworkErrorException**

*Guzzle ClientExcpetion*

-You can get guzzle exception by `getClientException()`

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

[](#dependencies)

- [GuzzleHttp ~5.2](https://packagist.org/packages/guzzlehttp/guzzle)
- [Uuid ^3.4](https://packagist.org/packages/ramsey/uuid)

Ortc Documentation
------------------

[](#ortc-documentation)

This package is based on ORTC REST API. You can download REST service documentation from this url:

```
http://messaging-public.realtime.co/documentation/rest/2.1.0/RestServices.pdf

```

Also, you can download official ORTC library for PHP from this url:

```
http://messaging-public.realtime.co/api/download/php/2.1.0/ApiPhp.zip

```

Framework Integrations
----------------------

[](#framework-integrations)

- **Laravel 4/5:** [nikapps/ortc-laravel](https://github.com/nikapps/ortc-laravel)

TODO
----

[](#todo)

- add UnitTest (codeception or phpunit) (Thanks to [@moura137](https://github.com/moura137))
- subscribe to channel(s) by Ratchet/Nodejs/Icicle/Amphp
- support mobile push notification (ios &amp; android)
- support presence channels
- Anything else?!

Contribute
----------

[](#contribute)

Wanna contribute? simply fork this project and make a pull request!

License
-------

[](#license)

This project released under the [MIT License](http://opensource.org/licenses/mit-license.php).

```
/*
 * Copyright (C) 2015 NikApps Team.
 *
 * 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:
 *
 * 1- The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * 2- 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.
 */

```

Donation
--------

[](#donation)

[![Donate via Paypal](https://camo.githubusercontent.com/e1ff554a09e8e92bef25abc553ff05b88f45afd695877cf12f3a46558ef65b2e/68747470733a2f2f7777772e70617970616c6f626a656374732e636f6d2f656e5f55532f692f62746e2f62746e5f646f6e61746543435f4c472e676966)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=G3WRCRDXJD6A8)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

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

Every ~0 days

Total

5

Last Release

3077d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7284321?v=4)[Diego Cortés](/maintainers/blenderdeluxe)[@blenderdeluxe](https://github.com/blenderdeluxe)

---

Top Contributors

[![blenderdeluxe](https://avatars.githubusercontent.com/u/7284321?v=4)](https://github.com/blenderdeluxe "blenderdeluxe (17 commits)")

---

Tags

apipushreal-timewrapperpublishrealtimepub-subrealtime.coORTCXRTML

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/blenderdeluxe-ortc-php/health.svg)

```
[![Health](https://phpackages.com/badges/blenderdeluxe-ortc-php/health.svg)](https://phpackages.com/packages/blenderdeluxe-ortc-php)
```

###  Alternatives

[pusher/pusher-php-server

Library for interacting with the Pusher REST API

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

This is the official PubNub PHP SDK repository.

1314.6M17](/packages/pubnub-pubnub)[gabrielbull/ups-api

PHP UPS API

4642.4M10](/packages/gabrielbull-ups-api)[walle89/swedbank-json

Unofficial API client for the Swedbank's and Sparbanken's mobile apps in Sweden.

752.5k](/packages/walle89-swedbank-json)[dariusiii/tmdb-laravel

Laravel Package for TMDB ( The Movie Database ) API. Provides easy access to the wtfzdotnet/php-tmdb-api library.

1821.1k](/packages/dariusiii-tmdb-laravel)[lasserafn/laravel-economic

Economic REST wrapper for Laravel

1118.5k](/packages/lasserafn-laravel-economic)

PHPackages © 2026

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