2017 © Pedro Peláez
 

library gepard-php

PHP client for gepard:General purpose communications for distributed applications / Microservices / events, semaphores and messages for JavaScript, Java, Python and PHP

image

gepard/gepard-php

PHP client for gepard:General purpose communications for distributed applications / Microservices / events, semaphores and messages for JavaScript, Java, Python and PHP

  • Wednesday, August 9, 2017
  • by gessinger-hj
  • Repository
  • 1 Watchers
  • 0 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

gepard-php

General purpose communication and synchronization layer for distributed applications / Microservices / events, semaphores, locks and messages for JavaScript, Java, Python and PHP, (*1)

Overview

This PHP module implements a simple client for the GEPARD middleware for general purpose distributed applications., (*2)

In order to use this PHP client you must have installed the GEPARD middleware. This is simply done by executing the command:, (*3)

    npm install gepard

Prerequisite for this command is the installation of node and npm. For more information see gepard on npm and gessinger-hj/gepard on github., (*4)

If you are interested in the python client see gepard-python on pypi and gepard-python on github, (*5)

Install

If you not yet have a composer.json create this file with the following content:, (*6)

{
    "require": {
        "gepard/gepard-php": ">=1.0"
    },
    "minimum-stability": "dev" 
}

If this composer.json file already exists in your project-directory add the body-lines above. After this is done execute the command:, (*7)

composer install

Usecases

Updating a Customer-record in the Database

Suppose there is a database containing customer base-data like for example name, id, enabled,..., (*8)

The access to the database for example is done with laravel/eloquent. The UPDATE is coded with the following code-snippet:, (*9)

$customer_Id = 1 ;
$customer = App\Customer::find($customer_id);

$customer->name = 'New Customer Name';

$customer->save();

Interested 3rd parties now are informed by sending an Event:, (*10)

Client::getInstance()->emit('CUSTOMER_CHANGED', ['CUSTOMER_ID' => $customer_id]);

Interested parties for example are:, (*11)

  • A Java program which sends an e-mail., (*12)

    Client.getInstance().on ( new String[] { "CUSTOMER_CHANGED" }, (e) -> {
        Integer customer_id = e.getValue ( "CUSTOMER_ID" ) ;
    
        *select customer from database with customer_id*
        *use any mail-api to send mail*
    } ) ;
    
  • A JavaScript program which sends an e-mail:, (*13)

    gepard.getClient().on ( 'CUSTOMER_CHANGED', (e) => {
        let customer_id = e.getValue ( 'CUSTOMER_ID' ) ;
    
        *select customer from database with customer_id*
        *use any mail-api to send mail*
    } ) ;
    
  • A Python program which sends an e-mail:, (*14)


    def on_CUSTOMER_CHANGED ( event ): customer_id = event.getValue ( 'CUSTOMER_ID' ) ; *select customer from database with customer_id* *use any mail-api to send mail* gepard.Client.getInstance().on ( 'CUSTOMER_CHANGED', on_CUSTOMER_CHANGED ) ;
  • A single page web-app or a React-native app, (*15)

    gepard.getWebClient().on ( 'CUSTOMER_CHANGED', (e) => {
        let customer_id = e.getValue ( 'CUSTOMER_ID' ) ;
    
        if ( customer-data are displayed in any part of the page ) {
            *select customer from database with customer_id via a REST call*
            *update appropriate display*
        }
    } ) ;
    
    

The Versions

09/08 2017

dev-master

9999999-dev

PHP client for gepard:General purpose communications for distributed applications / Microservices / events, semaphores and messages for JavaScript, Java, Python and PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Hans-Jürgen Gessinger