Skip to content

Commit

Permalink
first release
Browse files Browse the repository at this point in the history
  • Loading branch information
alibo committed Apr 3, 2015
0 parents commit 83e3a78
Show file tree
Hide file tree
Showing 13 changed files with 595 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/vendor
composer.phar
composer.lock
.DS_Store
/.idea
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
language: php

php:
- 5.4
- 5.5
- 5.6
- hhvm

before_script:
- travis_retry composer self-update
- travis_retry composer install --prefer-source --no-interaction --dev

script: phpunit
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Contribution Guidelines

Please submit all issues and pull requests to the [nikapps/ortc-laravel](http://github.com/nikapps/ortc-laravel) repository!
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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.
*/
184 changes: 184 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
# ORTC-Laravel (ORTC client for Laravel)

An Easy-To-Use ORTC API Client package for Laravel Framework (Laravel 4.2.x)



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

## Installation

Simply run command:

```
composer require nikapps/ortc-laravel
```

Or you can add this [package](https://packagist.org/packages/nikapps/ortc-laravel) dependency to your Laravel's composer.json :

~~~json
{
"require": {
"nikapps/ortc-laravel": "1.*"
}

}
~~~

Then update composer:

```
composer update
```

-

Add this package provider in your providers array `[app/config/app.php]`:

~~~php
'Nikapps\OrtcLaravel\OrtcLaravelServiceProvider',
~~~

Next you need to publish configuration file. Run this command:

```
php artisan config:publish nikapps/ortc-laravel
```


## Configuration

#### Get Application Key & Private Key
First of all, you should register on realtime.co and get your api keys.

* Login/Register at https://accounts.realtime.co

* 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

Edit `app/config/packages/nikapps/ortc-laravel/config.php`:

~~~php
'credentials' => [

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

],
~~~

#### Done!

## Usage

#### Get Balancer URL (Manually)

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

~~~php
$balancerUrl = Ortc::getBalancerUrl();

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

#### Authentication
In order to authenticate a user:

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

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

#### Send Message (Push)
In order to push a message to a channel:

~~~php
Ortc::send(
$channel, //channel name
$authToken, //authentication token
$message //message (string)
);
~~~

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

## Exceptions
See [nikapps/ortc-php - Exceptions](https://github.com/nikapps/ortc-php#exceptions)


## Dependencies

* [nikapps/ortc-php (1.x)](https://packagist.org/packages/nikapps/ortc-php)


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

```
http://ortc.xrtml.org/documentation/rest/2.1.0/RestServices.pdf
```

## TODO

* add UnitTest (codeception or phpunit)
* subscribe channel(s) by Ratchet/Nodejs
* support mobile push notification (ios & android)
* support presence channels
* create package for Laravel 5
* Anything else?!

## Contribute

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


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

[![Donate via Paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=G3WRCRDXJD6A8)
40 changes: 40 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "nikapps/ortc-laravel",
"description": "An API wrapper for ORTC (Real-Time framework from realtime.co) based on Laravel framework",
"keywords": [
"laravel",
"RealTime",
"realtime.co",
"ORTC",
"API",
"Wrapper",
"XRTML",
"pub-sub",
"push",
"publish",
"real-time"
],
"license": "MIT",
"type": "project",
"authors": [
{
"name": "Ali Borhani",
"email": "aliborhani1@gmail.com"
},
{
"name": "Hossein Moradgholi",
"email": "h.moradgholi@icloud.com"
}
],
"require": {
"php": ">=5.4.0",
"illuminate/support": "4.2.*",
"nikapps/ortc-php": "1.*"
},
"autoload": {
"psr-0": {
"Nikapps\\OrtcLaravel\\": "src/"
}
},
"minimum-stability": "stable"
}
18 changes: 18 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
17 changes: 17 additions & 0 deletions src/Nikapps/OrtcLaravel/OrtcLaravelFacade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
namespace Nikapps\OrtcLaravel;

use Illuminate\Support\Facades\Facade;

class OrtcLaravelFacade extends Facade
{
/**
* The name of the binding in the IoC container.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'Ortc';
}
}
Loading

0 comments on commit 83e3a78

Please sign in to comment.