1. Go to this page and download the library: Download ultraleet/currency-rates 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/ */
ultraleet / currency-rates example snippets
'providers' => [
// Other service providers...
Ultraleet\CurrencyRates\CurrencyRatesServiceProvider::class,
],
use Ultraleet\CurrencyRates\CurrencyRates;
class YourService
{
private $currencyRates;
public function __construct(CurrencyRates $currencyRates)
{
$this->currencyRates = $currencyRates;
}
}
use Ultraleet\CurrencyRates\CurrencyRates;
$currencyRates = new CurrencyRates;
$config = config('services.foo'); // Laravel example for fetching the config array
$result = $currencyRates->driver('foo')->configure($config)->...
$result = $currencyRates->driver('fixer')->target(['USD', 'GBP'])->get();
$result = $currencyRates->driver('fixer')->base('USD')->target(['EUR', 'GBP'])->get();
// you can provide a single target currency as a string
$result = $currencyRates->driver('fixer')->target('USD')->get();
$result = $currencyRates->driver('fixer')->latest('USD', ['EUR', 'GBP']);
$date = $result->getDate(); // Contains the date as a DateTime object
$rates = $result->getRates(); // Array of exchange rates
$gbp = $result->getRate('GBP'); // Rate for the specific currency, or null if none was provided/requested
$date = $result->date; // Contains the date as a DateTime object
$rates = $result->rates; // Array of exchange rates
$gbp = $result->rates['GBP']; // Rate for the specific currency
// Set the amount by chaining in an amount() call
$result = $currencyRates->driver('fixer')->amount(100)->target('USD')->get();
// Get the converted values
$values = $result->getConverted(); // returns an array of values
// You can also access the results as a property:
$value = $result->converted['USD']; // returns 120.07
use Ultraleet\CurrencyRates\CurrencyRatesManager;
use GuzzleHttp\Client as GuzzleClient;
use App\Currency\FooProvider;
public function boot(CurrencyRatesManager $manager)
{
$manager->extend('foo', function ($app) {
return new FooProvider(new GuzzleClient);
});
}
use Ultraleet\CurrencyRates\CurrencyRates;
use GuzzleHttp\Client as GuzzleClient;
use Namespace\Path\To\FooProvider; // replace with your actual class path
class ExtendedCurrencyRates extends CurrencyRates
{
protected function createFooDriver()
{
return new FooProvider(new GuzzleClient);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.