Skip to content

kakadu-dev/php-ijson-microservices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP 7.4 Inverted JSON Microservices

GitHub release (latest SemVer)

  • Gateway entrypoint (in-progress)
  • Microservice worker

Installation

The preferred way to install this extension is through composer.

Either run

composer require --prefer-dist kakadu-dev/php-ijson-microservices "*"

or add

"kakadu-dev/php-ijson-microservices": "@dev"

to the require section of your composer.json file.

Usage

Example microservice:

use Kakadu\Microservices\Microservice;

$app = Microservice::create('my-microservice', [
    'ijson' => 'http://127.0.0.1:8001',
    'env'   => 'dev',
], true);

$app->start(function ($method, $params) {
    // Run method with params
    // Return result

    return ['hello' => 'world'];
});

Start Inverted JSON:

version: '3.7'

services:
  ijson:
    image: lega911/ijson
    container_name: base-ijson
    ports:
      - 8001:8001

Send POST request directly to: http://localhost:8001

curl http://127.0.0.1:8001/my-microservice -d '{"id": 1, "params":{"test":1}}'

If you run gateway. Run POST request to: http://localhost:3000

{
  "id": 1,
  "method": "my-service.test-method",
  "params": {
    "test": 1
  }
}

That's all. Check it.