PHPackages                             blenderdeluxe/ortc-laravel - 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-laravel

ActiveProject[API Development](/categories/api)

blenderdeluxe/ortc-laravel
==========================

An API wrapper for ORTC (Real-Time framework from realtime.co) based on Laravel framework

1.5(8y ago)016MITPHPPHP &gt;=5.5.9

Since Dec 11Pushed 8y ago1 watchersCompare

[ Source](https://github.com/blenderdeluxe/ortc-laravel)[ Packagist](https://packagist.org/packages/blenderdeluxe/ortc-laravel)[ RSS](/packages/blenderdeluxe-ortc-laravel/feed)WikiDiscussions master Synced yesterday

READMEChangelog (6)Dependencies (2)Versions (7)Used By (0)

ORTC-Laravel (ORTC client for Laravel)
======================================

[](#ortc-laravel-ortc-client-for-laravel)

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

An Easy-To-Use [ORTC](http://framework.realtime.co/messaging) API Client for Laravel Framework (Laravel 5.1 and 5.2)

**If you're using Laravel 4.2.x, please check [branch l4](https://github.com/nikapps/ortc-laravel/tree/l4)**

*This package is based on [nikapps/ortc-php](https://github.com/nikapps/ortc-php).*

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

[](#installation)

You can install this [package](https://packagist.org/packages/nikapps/ortc-laravel) by simply run this composer command:

```
composer require nikapps/ortc-laravel

```

Then, add this service provider in your providers array `[app/config/app.php]`:

```
Nikapps\OrtcLaravel\OrtcLaravelServiceProvider::class,
```

Then, add this Facade to your aliases array `[app/config/app.php]`:

```
'Ortc' => Nikapps\OrtcLaravel\Facades\Ortc::class
```

Next you have to copy the configuration to your `connections` array `[app/config/broadcasting.php]`:

```
'realtime' => [
    'driver' => 'realtime',
    'credentials' => [

        /*
         * your application key
         */
        'application_key' => 'YOUR_APPLICATION_KEY',
        /*
         * your private key
         */
        'private_key'     => 'YOUR_PRIVATE_KEY',

    ],
    /*
    |--------------------------------------------------------------------------
    | Real-time REST API Options
    |--------------------------------------------------------------------------
    | you can change default options of api.
    |
    */
    'api'         => [
        /*
         * send message
         */
        'send_message'   => [
            'path'               => '/send', //api path
            'max_chunk_size'     => 700, //maximum size of each message in bytes
            'batch_pool_size'    => 5, //pool size for concurrent requests
            'pre_message_string' => '{RANDOM}_{PART}-{TOTAL_PARTS}_' //pre message string format
        ],
        /*
         * authentication
         */
        'authentication' => [
            'path' => '/authenticate' //api path
        ],
        /*
         * url to fetch balancer url
         */
        'balancer_url'   => 'https://ortc-developers.realtime.co/server/2.1?appkey={APP_KEY}',
        /*
         * verify ssl/tls certificate
         */
        'verify_ssl'     => true
    ]
]
```

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.

#### Update config file

[](#update-config-file)

Edit `app/config/broadcasting.php`:

```
/*
* set default broadcasting driver to realtime
*/
'default' => env('BROADCAST_DRIVER', 'realtime'),

'credentials' => [

    /*
     * your application key
     */
    'application_key' => 'YOUR_APPLICATION_KEY',
    /*
     * your private key
     */
    'private_key'     => 'YOUR_PRIVATE_KEY',

],
```

#### 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:

```
$balancerUrl = Ortc::getBalancerUrl();

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

#### Authentication

[](#authentication)

In order to authenticate a user:

```
$channels = [
	'channel_one' => 'w',
	'channel_two' => 'r'
];

Ortc::authenticate(
	$authToken, //authentication token
	$channels,
	$ttl, //(optional) default: 3600
	$isPrivate //(optional) default: false
);
```

#### Send Message via broadcasting service (recommend) (Push)

[](#send-message-via-broadcasting-service-recommend-push)

See [laravel/Events - Marking Events For Broadcast](http://laravel.com/docs/5.1/events#broadcasting-events)

Below a short example:

Create a new Event

```
php artisan make:event TestEvent

```

Open up app/Events/TestEvent.php and edit

```
