11# skoniks / php_cent
2- Centrifugo (Centrifuge) [ 1.6 +] PHP Server REDIS & HTTP API implementation for Laravel 5+
3-
2+ Centrifugo (Centrifuge) [ 1.0 +] PHP Server REDIS & HTTP API implementation for Laravel 5+
3+ Incompatible with Centrifugo [ 2.0+ ] , will be updated later!
44## Base Installation
551 . Run ` composer require skoniks/php_cent ` & ` composer update `
662 . Create ` config/centrifugo.php ` as provided below
@@ -9,17 +9,7 @@ Centrifugo (Centrifuge) [1.6+] PHP Server REDIS & HTTP API implementation for La
99> For laravel 5.5+ use version >= "2.5"
1010
1111## Config example ` config/centrifugo.php `
12- ``` php
13- <?php
14- return [
15- 'driver' => 'centrifugo', // redis channel name as provided in cent. conf ($driver.".api")
16- 'transport' => 'http', // http || redis connection, check more information below
17- 'redisConnection' => 'centrifugo', // only for redis, name of connection more information below
18- 'baseUrl' => 'http://localhost:8000/api/', // full api url
19- 'secret' => 'shlasahaposaheisasalssushku', // you super secret key
20- ];
21-
22- ```
12+ [ centrifugo.php] ( https://github.com/skoniks/php_cent/blob/master/centrifugo.php )
2313
2414## Alias additions ` config/app.php `
2515``` php
@@ -31,27 +21,25 @@ Centrifugo (Centrifuge) [1.6+] PHP Server REDIS & HTTP API implementation for La
3121```
3222
3323## Setting redis as transport
34- > Read notes about redis transport provided methods below. To set redis as transport :
35-
36- 1 . Add your redis connections add your connection to ` config/database.php ` as provided below
24+ 1 . Add your redis connection to ` config/database.php `
37252 . Change ` config/centrifugo.php ` to redis settings
3826
3927## Adding redis connection ` config/database.php `
4028``` php
41- 'redis' => [
29+ ...
30+ 'redis' => [
4231 ...
4332 'centrifugo' => [
44- 'scheme' => 'tcp', // unix
45- 'host' => '127.0.0.1', // null for unix
46- 'path' => '', // or unix path
33+ 'scheme' => 'tcp',
34+ 'host' => '127.0.0.1',
4735 'password' => '',
48- 'port' => 6379, // null for unix
49- 'database' => 1, // cent. db like in cent. configs
36+ 'port' => 6379,
37+ 'database' => 1,
5038 ],
5139 ],
40+ ...
5241```
5342
54-
5543## Redis supported transport
5644> Make shure that ** HTTP connection must work independently from redis connection** .
5745> It is because redis transport provides only this methods:
@@ -60,39 +48,42 @@ Centrifugo (Centrifuge) [1.6+] PHP Server REDIS & HTTP API implementation for La
6048* 'unsubscribe'
6149* 'disconnect'
6250
63- > Redis dont provides this methods:
51+ > Redis dont provide this methods:
6452* presence
6553* history
54+ * channels
55+ * stats
56+ * node
6657
6758## [ Module usage || sending your requests] example
6859``` php
6960<?php
7061use Centrifugo;
71-
72- class Controller
73- {
74- public function your_func()
75- {
62+ class Controller {
63+ public function _function(){
7664 // declare Centrifugo
77- $Centrifugo = new Centrifugo();
65+ $centrifugo = new Centrifugo();
7866
7967 // generating token example
8068 $current_time = time();
81- $steamid = '76561198073063637'
82- $token = $Centrifugo->generateToken($steamid, $current_time, '');
69+ $user_id = '1234567890';
70+ $token = Centrifugo::token($user_id, $current_time, 'custom info');
71+
8372 // publishing example
84- $Centrifugo ->publish("channel" , ["yout text or even what rou want "]);
73+ $centrifugo ->publish("channel" , ["custom data "]);
8574
86- // each method returns its response;
8775 // list of awailible methods:
88- $response = $Centrifugo->publish($channle, $messageData);
89- $response = $Centrifugo->unsubscribe($channle, $userId);
90- $response = $Centrifugo->disconnect($userId);
91- $response = $Centrifugo->presence($channle);
92- $response = $Centrifugo->history($channle);
93- $response = $Centrifugo->generateToken($user, $timestamp, $info);
94-
95- // You can create a controller to bild your own interface;
76+ $response = $centrifugo->publish($channel, $data);
77+ $response = $centrifugo->unsubscribe($channel, $user_id);
78+ $response = $centrifugo->disconnect($user_id);
79+ $response = $centrifugo->presence($channel);
80+ $response = $centrifugo->history($channel);
81+ $response = $centrifugo->channels();
82+ $response = $centrifugo->stats();
83+ $response = $centrifugo->node();
84+ $token = Centrifugo::token($user_id, $timestamp, $info);
85+
86+ // $response == false | when error
9687 }
9788```
98- ### For more informations go [ here] ( https://fzambia.gitbooks.io/centrifugal/content/ )
89+ ### For more information go [ here] ( https://fzambia.gitbooks.io/centrifugal/content/ )
0 commit comments