1. Go to this page and download the library: Download unirate/slim 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/ */
unirate / slim example snippets
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Psr7\HttpFactory;
use Slim\Factory\AppFactory;
use UniRate\Slim\UniRateClient;
use UniRate\Slim\UniRateConfig;
use UniRate\Slim\UniRateMiddleware;
use function UniRate\Slim\registerUniRateRoutes;
$guzzle = new GuzzleClient();
$factory = new HttpFactory();
$client = new UniRateClient(
new UniRateConfig(getenv('UNIRATE_API_KEY')),
$guzzle, // PSR-18 ClientInterface
$factory, // PSR-17 RequestFactoryInterface
$factory, // PSR-17 UriFactoryInterface
);
$app = AppFactory::create();
$app->add(new UniRateMiddleware($client));
registerUniRateRoutes($app); // adds /unirate/rate, /convert, /currencies, /vat
$app->run();
$config = new UniRateConfig('your-key'); // default base URL
$config = UniRateConfig::fromArray([
'api_key' => 'your-key',
'base_url' => 'https://api.unirateapi.com',
]);