1. Go to this page and download the library: Download hennest/exchange-rate 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/ */
hennest / exchange-rate example snippets
'providers' => [
// Other Service Providers
Hennest\ExchangeRate\Providers\ExchangeRateServiceProvider::class,
],
use Hennest\ExchangeRate\Contracts\ExchangeRateInterface;
class ExampleController
{
public function __construct(
private ExchangeRateInterface $exchangeRate
) {}
public function example()
{
// Get exchange rates for specific currencies
$rates = $this->exchangeRate->rates(['EUR', 'GBP', 'JPY']);
// Get a single exchange rate
$rate = $this->exchangeRate->getRate('EUR');
// Convert currency
$convertedAmount = $this->exchangeRate->convert(100, 'USD', 'EUR');
}
public function anotherExample()
{
// Get exchange rates for specific currencies
$rates = app(ExchangeRateInterface::class)->rates(['EUR', 'GBP', 'JPY']);
// Get a single exchange rate
$rate = app(ExchangeRateInterface::class)->getRate('EUR');
// Convert currency
$convertedAmount = app(ExchangeRateInterface::class)->convert(100, 'USD', 'EUR');
}
}