2017 © Pedro PelĂĄez
 

symfony-bundle open-exchange-rates-bundle

OpenExchangeRates API exposure for Symfony2

image

mrzard/open-exchange-rates-bundle

OpenExchangeRates API exposure for Symfony2

  • Friday, December 1, 2017
  • by mrzard
  • Repository
  • 2 Watchers
  • 9 Stars
  • 3,908 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 15 Versions
  • 4 % Grown

The README.md

OpenExchangeRates for Symfony2

SensioLabsInsight Scrutinizer Code Quality Build Status, (*1)

Version families

Branch 2.0.0 will give support to Symfony >= 2.3, (*2)

Branch 3.0.0 will give support to Symfony >=3 (WIP), (*3)

Installation

``` bash $ php composer.phar require mrzard/open-exchange-rates-bundle ~2.0.0, (*4)


And register the bundle in your AppKernel.php file ``` php return array( // ... new Mrzard\OpenExchangeRatesBundle\OpenExchangeRatesBundle(), // ... );

Configuration

You will have to define your api id in the parameters.yml file of you environment., (*5)

Then, add this to your services.yml file ``` yml open_exchange_rates: api_id: %YOUR_API_ID_PARAM% api_configuration: https: true|false #defaults to false base_currency: XXX #defaults to USD, (*6)


If you're using a free version, you won't need to change the `https` or `base_currency` as they only work fror Enterprise/Unlimited accounts ## Usage You can access the service by getting it from the container under open_exchange_rates_service Keep in mind that some options will only work properly with an Enterprise/Unlimited Plan ## Free features ### Get latest exchange rates ``` php /** * Get the latest exchange rates * * @param array $symbols Currency codes to get the rates for. Default all * @param string $base Base currency, default NULL (gets it from config) * * @return array */ public function getLatest($symbols = array, $base = null) { }

Only use the $symbols and $base parameters if you have an Enterprise or Unlimited plan., (*7)

Output:, (*8)

array (size=5)
  'disclaimer' => string 'Exchange rates...'
  'license' => string 'Data sourced from...'
  'timestamp' => int 1395396061
  'base' => string 'USD' (length=3)
  'rates' =>
    array (size=166)
      'AED' => float 3.672721
      'AFN' => float 56.747225
      'ALL' => float 101.7573
      'AMD' => float 417.366998
      ...
    )
)

Get available currencies

``` php /** * Gets a list of all available currencies * * @return array with keys = ISO codes, content = Currency Name */ public function getCurrencies() { }, (*9)


Output:

array (size=5) 'AED' => 'United Arab Emirates Dirham' 'AFN' => 'Afghan Afghani' 'ALL' => 'Albanian Lek' 'AMD' => 'Armenian Dram' 'ANG' => 'Netherlands Antillean Guilder' ... ), (*10)



### Get historical data for a date ``` php /** * Get historical data * * @param \DateTime $date */ public function getHistorical(\DateTime $date) { }

Output:, (*11)

array (size=5)
  'disclaimer' => string 'Exchange rates...'
  'license' => string 'Data sourced from...'
  'timestamp' => int 1388617200
  'base' => string 'USD' (length=3)
  'rates' =>
    array (size=166)
      'AED' => float 3.672524
      'AFN' => float 56.0846
      'ALL' => float 102.06575
      'AMD' => float 408.448002
      'ANG' => float 1.78902
      'AOA' => float 97.598401
      'ARS' => float 6.51658
      'AUD' => float 1.124795
      'AWG' => float 1.789775
      'AZN' => float 0.7841
      'BAM' => float 1.421715
      'BBD' => int 2
      ...
    )
)

Developer / Unlimited features

Get the latest exchange rates, limiting the return array

``` php $openExchangeRatesService->getLatest(['EUR', 'USD', 'COP']);, (*12)


Output:

array (size=5) 'disclaimer' => string 'Exchange rates ...' 'license' => string 'Data sourced...' 'timestamp' => int 1395396061 'base' => string 'USD' (length=3) 'rates' => array (size=3) 'EUR' => ..., 'USD' => ..., 'COP' => ... ) ), (*13)


You can also change the base currency used to get the latest exchange rates with the second parameter ### Directly convert a quantity between currencies ``` php $openExchangeRatesService->convert(10, 'USD', 'EUR');

The Versions

01/12 2017

v3.x-dev

3.9999999.9999999.9999999-dev

OpenExchangeRates API exposure for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gonzalo MĂ­guez

01/12 2017

v3.0.1

3.0.1.0

OpenExchangeRates API exposure for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gonzalo MĂ­guez

01/12 2017

dev-master

9999999-dev

OpenExchangeRates API exposure for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gonzalo MĂ­guez

01/12 2017

v2.x-dev

2.9999999.9999999.9999999-dev

OpenExchangeRates API exposure for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gonzalo MĂ­guez

01/12 2017

v2.1.4

2.1.4.0

OpenExchangeRates API exposure for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gonzalo MĂ­guez

26/05 2017

v2.1.3

2.1.3.0

OpenExchangeRates API exposure for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gonzalo MĂ­guez

26/05 2017

v2.1.2

2.1.2.0

OpenExchangeRates API exposure for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gonzalo MĂ­guez

16/12 2016

v3.0.0

3.0.0.0

OpenExchangeRates API exposure for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gonzalo MĂ­guez

11/08 2016

v2.1.1

2.1.1.0

OpenExchangeRates API exposure for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gonzalo MĂ­guez

09/08 2016

v2.1.0

2.1.0.0

OpenExchangeRates API exposure for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gonzalo MĂ­guez

06/07 2016

v2.0.0

2.0.0.0

OpenExchangeRates API exposure for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gonzalo MĂ­guez

16/01 2015

v0.2.0

0.2.0.0

OpenExchangeRates API exposure for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gonzalo MĂ­guez

23/10 2014

v0.1.2

0.1.2.0

OpenExchangeRates API exposure for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gonzalo MĂ­guez

04/08 2014

v0.1.1

0.1.1.0

OpenExchangeRates API exposure for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gonzalo MĂ­guez

26/03 2014

v0.1.0

0.1.0.0

OpenExchangeRates API exposure for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gonzalo MĂ­guez