PHP code example of memuya / fabdb-php-sdk

1. Go to this page and download the library: Download memuya/fabdb-php-sdk 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/ */

    

memuya / fabdb-php-sdk example snippets


use Memuya\Fab\Client;

$client = new Client;

use Memuya\Fab\FleshAndBlood;

$fab = new FleshAndBlood($client);

new \Memuya\Fab\Formatter\JsonFormatter; // Accept: application/json
new \Memuya\Fab\Formatter\XmlFormatter; // Accept: application/xml
new \Memuya\Fab\Formatter\CsvFormatter; // Accept: text/csv

// Via the contructor.
$client = new Client(new JsonFormatter);

// Via the setter.
$client->setFormatter(new JsonFormatter);

use Memuya\Fab\Enums\Set;
use Memuya\Fab\Enums\Pitch;
use Memuya\Fab\Enums\Rarity;
use Memuya\Fab\Enums\HeroClass;
use Memuya\Fab\Exceptions\InvalidCardConfigException;

try {
    $fab->getCards([
        'page' => 1,
        'per_page' => 10,
        'keywords' => 'search terms',
        'cost' => '1',
        'pitch' => Pitch::One,
        'class' => HeroClass::Brute,
        'rarity' => Rarity::Common,
        'set' => Set::WelcomeToRathe,
    ]);
} catch (InvalidCardConfigException $ex) {
    // Handle exception...
}

use Memuya\Fab\Enums\Set;
use Memuya\Fab\Enums\Pitch;
use Memuya\Fab\Enums\Rarity;
use Memuya\Fab\Enums\HeroClass;
use Memuya\Fab\Endpoints\Cards\CardsConfig;
use Memuya\Fab\Endpoints\Cards\CardsEndpoint;
use Memuya\Fab\Exceptions\InvalidCardConfigException;

try {
    $cards = $client->sendRequest(
        new CardsEndpoint(
            new CardsConfig([
                'page' => 1,
                'per_page' => 10,
                'keywords' => 'search terms',
                'cost' => '1',
                'pitch' => Pitch::One,
                'class' => HeroClass::Brute,
                'rarity' => Rarity::Common,
                'set' => Set::WelcomeToRathe,
            ])
        )
    );
} catch (InvalidCardConfigException $ex) {
    // Handle exception...
}

$fab->getCard('ARC000');

use Memuya\Fab\Endpoints\Card\CardConfig;
use Memuya\Fab\Endpoints\Card\CardEndpoint;

$client->sendRequest(
    new CardEndpoint(
        new CardConfig(['identifier' => 'ARC000'])
    )
);

$fab->getDeck('deck-slug');

use Memuya\Fab\Endpoints\Deck\DeckConfig;
use Memuya\Fab\Endpoints\Deck\DeckEndpoint;

$client->sendRequest(
    new DeckEndpoint(
        new DeckConfig(['slug' => 'deck-slug'])
    )
);

composer