PHP code example of peso / moneyphp-exchange
1. Go to this page and download the library: Download peso/moneyphp-exchange 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/ */
peso / moneyphp-exchange example snippets
use Money\Converter;
use Money\Currencies\ISOCurrencies;
use Money\Currency;
use Money\Money;
use Peso\Money\PesoConverter;
use Peso\Money\PesoExchange;
use Peso\Services\EuropeanCentralBankService;
$exchange = new PesoExchange(new EuropeanCentralBankService());
$eur100 = Money::EUR(10000);
$converter = new Converter(new ISOCurrencies(), $exchange);
var_dump($converter->convert($eur100, new Currency('USD'))); // Money::USD(...)
// or
$converter = new PesoConverter(new ISOCurrencies(), $exchange);
var_dump($converter->convert($eur100, new Currency('USD'))); // Money::USD(...)
var_dump($converter->convertOnDate($eur100, new Currency('USD')), '2026-04-29'); // Money::USD(11706)