The PHP SDK
Installation
-
Install the SDK using Composer
Terminal window composer require tcgdex/sdk -
if you don’t have the PSRs 16,17 & 18 implementations, you can quickly add them using this command
Terminal window composer require symfony/cache nyholm/psr7 kriswallsmith/buzzTerminal window composer require nyholm/psr7
Usage
// import the packageuse TCGdex\TCGdex;
// if you use another anything else than the recommended you need to add them hereTCGdex::$cache = /* PSR16 CacheInterface */;TCGdex::$requestFactory = /* PSR17 RequestFactoryInterface */;TCGdex::$responseFactory = /* PSR17 ResponseFactoryInterface */;TCGdex::$client = /* PSR18 ClientInterface */;
// initialize the SDK with the language$tcgdex = new TCGdex("en");
// Fetch the cards !$card = $tcgdex->fetchCard('136', 'swsh3');
To setup TCGdex for Symfony you need to add the PSR 18 implementation (as it’s not the default one) and the PSR17 implementation if it’s not the default one
use TCGdex\TCGdex;use Symfony\Component\HttpClient\Psr18Client;
// if you use another anything else than nyholm/psr7 you need to add them hereTCGdex::$requestFactory = /* PSR17 RequestFactoryInterface */;TCGdex::$responseFactory = /* PSR17 ResponseFactoryInterface */;
// use Symfony PSR18 clientTCGdex::$client = new Psr18Client(); /* PSR18 ClientInterface */;
// initialize the SDK with the language$tcgdex = new TCGdex("en");
// Fetch the cards !$card = $tcgdex->fetchCard('136', 'swsh3');
You can check in the JSON REST API docs and select the correct tab to see the command specific for your SDK