Build Status Latest stable

Is required guzzle/guzzle 6.1+ and php 5.5+. If you have php < 5.5 use older version [v4.1.0] it work but does not use guzzle.

Exchange is PHP script works with currencies. This extension is primary for Nette framework 2+, but you can use without Nette for another framework or without framework.

Dependency on NumberFormat.

Installation to project

The best way to install h4kuna/exchange is using Composer:

$ composer require h4kuna/exchange

Example NEON config

	exchange: h4kuna\Exchange\Nette\DI\ExchangeExtension

		czk: [decimal: 0, symbol: '', point: ',', thousand: ' ', mask: '1 S', flag: 10]
		usd: [symbol: '$']
		gbp: [mask: 'S1', thousand: '.', symbol: '£', decimal: 2] }
		eur: [symbol: '']
    vat: 21
    vatIn: false
    vatOut: false
	filterName: currency # optional, new instaled macro whose prepared to use

Basic usage.

/* @var $exchange h4kuna\Exchange\Exchange */
$exchange->setDate(new DateTime('2000-12-30'));
$exchange->format(10, 'eur', 'czk'); // 351 Kč

Method format has parameters: - money (int/float) - from, this can be global set by method setDefault() - to, this can be global set by method setWeb() - vat, this can be global set by method setVat()

If you want all currencies. Default is load whose are in config.

$exchange->loadAll(); // array of h4kuna\Exchange\Currency\IProperty

Change default currency. Normaly default is first in config.

$this->exchange->format(10); // 10 Kč
$exchange->format(10); // 564 Kč, there is czk output
$exchange->format(10, NULL, 'gbp'); // £10.00
// or
$exchange->format(10); // £10.00

Change driver on fly.

$exchange->setDate(); // reset history to current
$ecbDriver = $exchange->setDriver(new Driver\Ecb\Day); // Ecb does not support history, yet


Filter currency is default, here is example how use. Parameters are optional.


No release at this moment. Try to create first one.

Is this addon outdated? Did you find an issue? Please report it.

Componette Componette