PHP code example of godmodelabs / flora-client-php

1. Go to this page and download the library: Download godmodelabs/flora-client-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

godmodelabs / flora-client-php example snippets


$client = new \Flora\Client('http://api.example.com/');
$response = $client->execute([
    'resource'  => 'foo',
    'select'    => 'id,name'
]);

$client = new \Flora\Client('http://api.example.com/');
$response = $client->executeRaw([
    'resource' => 'article',
    'id' => 1337,
    'action' => 'pdf',
]);

use GuzzleHttp\Promise;

$client = new \Flora\Client('http://api.example.com/');
try {
    $fooPromise = $client->executeAsync([
        'resource' => 'foo',
        'select' => 'id,name'
    ]);
    $barPromise = $client->executeAsync([
        'resource' => 'bar',
        'select' => 'id,name'
    ]);
    
    [$fooResponse, $barResponse] = Promise\Utils::unwrap([$fooPromise, $barPromise]);
    // process responses...
} catch (Throwable $e) {
    echo $e->getMessage(), PHP_EOL;
}

$client = new \Flora\Client('http://api.example.com/');
try {
    [$fooResponse, $barResponse] = $client->executeParallel([
        ['resource' => 'foo', 'select' => 'id,name'],
        ['resource' => 'bar', 'select' => 'id,name']
    ]);
    // process responses...
} catch (Throwable $e) {
    echo $e->getMessage(), PHP_EOL;
}