openbuildings/monetary

Useful tool for formatting and converting currencies

0.5.0 2020-02-21 09:15 UTC

This package is auto-updated.

Last update: 2024-10-21 20:21:07 UTC


README

Useful tool for formatting and converting currencies in PHP

Build Status Latest Stable Version

The main features are:

  • formatting an amount in a certain currency;
  • converting an amount from one currency to another.

The Monetary library takes care of fetching exchange rates from remote services and caching them.

You can easily use your own exchange rates source or cache solution.

Installation

Install via Composer

composer require openbuildings/monetary

Basic Usage

Use the namespace:

use OpenBuildings\Monetary\Monetary;

then just convert and format currencies:

echo Monetary::instance()->convert(10, 'USD', 'GBP');
// 7.5091987684914

echo Monetary::instance()->format(15.3, 'GBP');
// £15.30