### Install Currencycloud PHP Client via Composer Source: https://github.com/currencycloud/currencycloud-php/blob/master/README.md Use this command to add the Currencycloud SDK to your project using Composer. ```bash composer require currency-cloud/client ``` -------------------------------- ### PHP SDK Basic Usage Example Source: https://github.com/currencycloud/currencycloud-php/blob/master/README.md Demonstrates how to initialize the SDK, authenticate, fetch available currencies and balances, and close the session. Ensure you have the vendor autoload file included. ```php use CurrencyCloud\CurrencyCloud; use CurrencyCloud\Session; require_once __DIR__ . '/vendor/autoload.php'; $session = new Session( Session::ENVIRONMENT_DEMONSTRATION, '', '' ); $client = CurrencyCloud::createDefault($session); //Authenticate $client->authenticate() ->login(); //Get available currencies $currencies = $client->reference() ->availableCurrencies(); echo "Supported currencies:\n"; foreach ($currencies as $currency) { printf( "Currency: %s; Code: %s; Decimal places: %d\n", $currency->getName(), $currency->getCode(), $currency->getDecimalPlaces() ); } echo "Balances:\n"; //Find balances $balances = $client->balances() ->find(); foreach ($balances->getBalances() as $balance) { printf( "Balance ID: %s; Currency: %s; Amount: %s\n", $balance->getId(), $balance->getCurrency(), $balance->getAmount() ); } //Close session $client->authenticate()->close(); ``` -------------------------------- ### Include Composer Autoloader Source: https://github.com/currencycloud/currencycloud-php/blob/master/README.md After installing the SDK with Composer, include the autoloader file to enable class autoloading. ```php require 'vendor/autoload.php'; ``` -------------------------------- ### Deprecated Feature Announcement Source: https://github.com/currencycloud/currencycloud-php/blob/master/README.md This snippet shows an example of how a deprecated feature is announced, including the date of deprecation and the recommended alternative. Use this format for announcing feature deprecations. ```text - 2026-04-29: Beneficiary::create() - Use Beneficiary::createWithRequired() instead ``` -------------------------------- ### Clone the Repository Source: https://github.com/currencycloud/currencycloud-php/blob/master/CONTRIBUTING.md Clone the currencycloud-php repository to your local machine to begin making changes. Ensure you are cloning from your own fork. ```Shell git clone git@github.com:your-username/currencycloud-php.git ``` -------------------------------- ### PHP CurrencyCloudException Error Details Source: https://github.com/currencycloud/currencycloud-php/blob/master/README.md Illustrates the structure of a CurrencyCloudException when an API error occurs. The exception provides detailed information about the error, including request and response specifics. ```yaml BadRequestException --- platform: 'PHP 7.1.11-1+deb.sury.org~trusty+1' request: parameters: { } verb: get url: 'https://devapi.currencycloud.com/v2/rates/detailed?buy_currency=EUR&sell_currency=GBP&fixed_side=buy&amount=10000.00' response: status_code: 400 date: 'Tue, 13 Nov 2018 13:40:00 GMT' request_id: '2915002181730358306' errors: - field: base code: rate_could_not_be_retrieved message: 'Rate could not be retrieved' params: { } ``` -------------------------------- ### Making API Calls On Behalf Of Another User Source: https://github.com/currencycloud/currencycloud-php/blob/master/README.md This snippet shows how to execute SDK commands for a specific contact ID using the 'onBehalfOf' method. Transactions made this way are scoped to the contact's limits and linked to them. ```php $client->onBehalfOf('c6ece846-6df1-461d-acaa-b42a6aa74045', function (CurrencyCloud $client) { $balances = $client->balances() ->find(); foreach ($balances->getBalances() as $balance) { printf( "Balance ID: %s; Currency: %s; Amount: %s\n", $balance->getId(), $balance->getCurrency(), $balance->getAmount() ); } }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.