2017 © Pedro Peláez
 

library money

A library for working with the Open Exchange Rates API in PHP

image

amelia/money

A library for working with the Open Exchange Rates API in PHP

  • Wednesday, November 18, 2015
  • by amelia
  • Repository
  • 1 Watchers
  • 2 Stars
  • 28 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

Money.php

Build Status Scrutinizer Latest Stable Version MIT License, (*1)

A PHP 5.4+ library for working with currency APIs and conversion., (*2)

Current Providers for data are:, (*3)

  • Open Exchange Rates (https://openexchangerates.org)

Planned:, (*4)

  • Her Majesty's Revenue & Customs (http://www.hmrc.gov.uk/softwaredevelopers/2015-exrates.htm)
  • XE.com (https://xe.com)

Feel free to add more!, (*5)

Usage

To dive in with the OpenExchangeRates API implementation, go sign up for an app id. It's free!, (*6)

Laravel 5

Money ships with a Laravel 5 service provider., (*7)

Simply add Amelia\Money\MoneyServiceProvider::class to your providers array in config/app.php., (*8)

You can type-hint Amelia\Money\FactoryInterface in controllers (or more importantly, form requests), or use app(FactoryInterface::class) to fetch it from the IoC container., (*9)

<?php

use Amelia\Money\FactoryInterface;

class FooController extends Controller {
    public function __construct(FactoryInterface $money) {
        $money->convert($amount = 130.01, $from = "USD", $to = "GBP");
        $money->getBase();
        $money->getRates();
        $newMoney = $money->base("GBP"); // switch the base currency
    }
}

Add the following configuration to the config/services.php array, (*10)

"money" => [
    "api" => env("MONEY_API_TYPE", "openexchangerates"),
    "key" => env("MONEY_API_KEY", null),
],

Usage without a framework:

<?php

use Amelia\Money\OpenExchangeRatesFactory;
$converter = OpenExchangeRatesFactory::create(["key" => "YOUR_APP_ID"]);

$converter->convert(140, "gbp", "nok"); // currency codes are case-insensitive.
var_dump($converter->getRates(), $converter->getBase());

Converter instances are immutable. To change the base currency, use the ->base(string $base) method. To change the rates, make a new object., (*11)

The Versions

18/11 2015

dev-master

9999999-dev

A library for working with the Open Exchange Rates API in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Amelia Ikeda

currency money open exchange rates openexchangerates

18/11 2015

dev-analysis-XavL7q

dev-analysis-XavL7q

A library for working with the Open Exchange Rates API in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Amelia Ikeda

currency money open exchange rates openexchangerates

18/11 2015

dev-analysis-q2pAB8

dev-analysis-q2pAB8

A library for working with the Open Exchange Rates API in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Amelia Ikeda

currency money open exchange rates openexchangerates

28/08 2015

v1.0.0-beta.2

1.0.0.0-beta2

A library for working with the Open Exchange Rates API in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Amelia Ikeda

currency money open exchange rates openexchangerates

20/08 2015

dev-analysis-8QDm3z

dev-analysis-8QDm3z

A library for working with the Open Exchange Rates API in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Amelia Ikeda

currency money open exchange rates openexchangerates

30/07 2015

v1.0.0-beta.1

1.0.0.0-beta1

A library for working with the Open Exchange Rates API in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Amelia Ikeda

currency money open exchange rates openexchangerates

28/07 2015

v0.3.1

0.3.1.0

A library for working with the Open Exchange Rates API in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Amelia Ikeda

currency money open exchange rates openexchangerates

28/07 2015

v0.3.0

0.3.0.0

A library for working with the Open Exchange Rates API in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Amelia Ikeda

currency money open exchange rates openexchangerates

01/07 2015

v0.2.0

0.2.0.0

A library for working with the Open Exchange Rates API in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Amelia Ikeda

currency money open exchange rates openexchangerates

18/06 2015

v0.1.0

0.1.0.0

A library for working with the Open Exchange Rates API in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Amelia Ikeda

currency money open exchange rates openexchangerates