2017 © Pedro Peláez
 

package informers-client-php

image

deliverynetwork/informers-client-php

  • Monday, March 16, 2015
  • by deliverynetwork
  • Repository
  • 2 Watchers
  • 0 Stars
  • 45 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

Informers client PHP library

Installation

Through composer:

"deliverynetwork/informers-client-php": "dev-master",

Through including files:

<?php
include_once "<PATH_TO_LIBRARY>/src/Client.php";
include_once "<PATH_TO_LIBRARY>/src/FileCache.php";
include_once "<PATH_TO_LIBRARY>/src/ClientException.php";
include_once "<PATH_TO_LIBRARY>/src/MemoryCache.php";
include_once "<PATH_TO_LIBRARY>/src/TemplateEngine.php";

Usage

Usage with file cache:

<?php
try {
    $client = new \informers\client\Client(
        array(
            'site_id' => <YOUR_SITE_ID>,
            'api_key' => '<YOUR_SITE_API_KEY>',
            'api_url' => '<PLATFORM_API_URL>',
            'cache'   => new \informers\client\FileCache(
                '<PATH_TO_CACHE_DIRECTORY>',
                '<CACHE_PERIOD_IN_SECONDS>'
            )
        )
    );
    $currentUrl = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";// current page URL
    echo $client->render($currentUrl); // rendering informer
} catch (\informers\client\ClientException $e) { /* do something if needed */ } 

Usage with Memcached:

<?php
try {
    $client = new \informers\client\Client(
        array(
            'site_id' => <YOUR_SITE_ID>,
            'api_key' => '<YOUR_SITE_API_KEY>',
            'api_url' => '<PLATFORM_API_URL>',
            'cache'   => new \informers\client\MemoryCache(             
                array(
                    'host' => 'localhost',  // Memcached  host
                    'port' => 11211,        // Memcached  port
                ), '<CACHE_PERIOD_IN_SECONDS>'
            ),
        )
    );
    $currentUrl = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; // current page URL    
    echo $client->render($currentUrl); // rendering informer
} catch (\informers\client\ClientException $e) { /* do something if needed */ } 

Usage with custom cache

try {
    $client = new \informers\client\Client(
        array(
            'site_id' => <YOUR_SITE_ID>,
            'api_key' => '<YOUR_SITE_API_KEY>',
            'api_url' => '<PLATFORM_API_URL>',
            'cache'   => new \informers\client\CustomCache(
                    function($key){
                        return your_cache_get_function($key);
                    },
                    function($key, $value, $period){
                        return your_cache_set_function($key, $value, $period);
                    }, '<CACHE_PERIOD_IN_SECONDS>', '<CACHE_PREFIX>')
        )
    );
    $currentUrl = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; // current page URL    
    echo $client->render($currentUrl); // rendering informer
} catch (\informers\client\ClientException $e) { /* do something if needed */ }

The Versions

16/03 2015

dev-master

9999999-dev

  Sources   Download

ASL

16/03 2015

1.0.7

1.0.7.0

  Sources   Download

ASL

12/03 2015

1.0.6

1.0.6.0

  Sources   Download

ASL

09/03 2015

1.0.5

1.0.5.0

  Sources   Download

ASL

06/03 2015

1.0.4

1.0.4.0

  Sources   Download

ASL

10/02 2015

1.0.3

1.0.3.0

  Sources   Download

ASL

06/02 2015

1.0.2

1.0.2.0

  Sources   Download

ASL

06/02 2015

1.0.1

1.0.1.0

  Sources   Download

ASL

05/02 2015

1.0.0

1.0.0.0

  Sources   Download

ASL