PHP and Laravel package for Fixer.io

Fixer.io is a simple and lightweight API for current and historical foreign exchange rates. We came across this wonderful service while developing a recent project. I searched but couldn’t find any Fixer.io PHP client fitting our needs for the project so I decided to build a PHP and Laravel package for the same.

Fixer.io PHP Client

This is a standalone PHP client for fixer.io. It can be easily installed using composer.
composer require ranium/fixerio-php-client

After installation, you can use the client in your code as follows:

<?php
use Ranium\Fixerio\Client;

$accessKey = '12345678901234567890';
$secure = true; // Optional, default is true (only paid plans of fixer.io supports SSL)
$config = []; // Optional, guzzle command client config that you might want to pass

$fixerio = Client::create($accessKey, $secure, $config);

$latestRates = $fixerio->latest(
    [
        'base' => 'USD', // optional
        'symbols' => 'INR', // optional
    ]
);

// Display the INR rates
echo $latestRates['rates']['INR'];
?>

You can find the complete installation and usage instructions on the Github project page. Please feel free to report issues or feature requests on Github.

Fixer.io Laravel 5 Package

At Ranium, our framework of choice is Laravel. And the project where we needed a client for fixer.io was being developed in Laravel. So I went ahead and created a Laravel wrapper for the fixer.io PHP client.

You can install the Laravel package with:

composer require ranium/laravel-fixerio

After installation, you need to publish the fixer.io config file.

php artisan vendor:publish --tag=laravel-fixerio

Then edit the fixerio.php config file to put your access key and configure the caching. The Laravel package comes with an additional feature of caching the API responses. This saves your monthly fixer.io bill.

The usage is as simple as

<?php
use Fixerio;

$latestRates = Fixerio::latest();
?>

For more details, configuration options and usage please refer the Laravel Fixer.io Github project page. Please feel free to report issues or feature requests on Github.

Note: For more details on all the available API methods and endpoints, please refer the official fixer.io documentation.

Abbas Ali Administrator
Abbas is a seasoned programmer with over 15 years of experience in software development. His core expertise is web development using PHP, Laravel, NodeJS, VueJS, and various other open source technologies. Abbas is also the author of the book Sphinx Search: Beginner's Guide published by Packt Publishing, UK. Abbas is an active open source contributor with Coppermine Photo Gallery being one of his most popular projects having millions of download on sourceforge.
follow me

Leave a Reply

avatar
  Subscribe  
Notify of