PHPackages                             elliotwms/abacus - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. elliotwms/abacus

AbandonedLibrary[Utility &amp; Helpers](/categories/utility)

elliotwms/abacus
================

Currency conversion from the future

0.1.1(11y ago)1332[1 issues](https://github.com/elliotwms/Abacus/issues)MITPHP

Since Feb 22Pushed 10y ago1 watchersCompare

[ Source](https://github.com/elliotwms/Abacus)[ Packagist](https://packagist.org/packages/elliotwms/abacus)[ RSS](/packages/elliotwms-abacus/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

Abacus
======

[](#abacus)

[![Build Status](https://camo.githubusercontent.com/766659d701dfb8271cae50bae3f3d94f93d1c96804d59e09a1d7c9a437e1e13c/68747470733a2f2f7472617669732d63692e6f72672f656c6c696f74776d732f4162616375732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/elliotwms/Abacus)[![Latest Stable Version](https://camo.githubusercontent.com/32a8752d91854bab841ba64b49642ecd51be85a926dd4d45c88d80c73e3ae331/68747470733a2f2f706f7365722e707567782e6f72672f656c6c696f74776d732f6162616375732f762f737461626c652e737667)](https://packagist.org/packages/elliotwms/abacus)[![Latest Unstable Version](https://camo.githubusercontent.com/d1ee85d0e6dd3185fffc440bea60dcbf29acaa893ad01f88e65c4a7d419b2332/68747470733a2f2f706f7365722e707567782e6f72672f656c6c696f74776d732f6162616375732f762f756e737461626c652e737667)](https://packagist.org/packages/elliotwms/abacus)[![Total Downloads](https://camo.githubusercontent.com/2e47bb35d6fa761622e4092df96994ef7203d1ce3dca6abb081cae2d61e2ad7d/68747470733a2f2f706f7365722e707567782e6f72672f656c6c696f74776d732f6162616375732f646f776e6c6f6164732e737667)](https://packagist.org/packages/elliotwms/abacus)[![License](https://camo.githubusercontent.com/1a5c6f49941ed7f9069f5b34f55add50c69f916ba2ae1069dff33f5c5681ffe5/68747470733a2f2f706f7365722e707567782e6f72672f656c6c696f74776d732f6162616375732f6c6963656e73652e737667)](https://packagist.org/packages/elliotwms/abacus)[![Code Climate](https://camo.githubusercontent.com/8fa36cf8f5c9b2109c1f530a70212d69737db602af8382244702c3ee5e39cef6/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f656c6c696f74776d732f4162616375732f6261646765732f6770612e737667)](https://codeclimate.com/github/elliotwms/Abacus)[![Test Coverage](https://camo.githubusercontent.com/ee1691e3ce3cf3558c751a5161e491251225dbc5a0cdbb58ecdbfafe3f6f2aaf/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f656c6c696f74776d732f4162616375732f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/elliotwms/Abacus)[![Join the chat at https://gitter.im/elliotwms/Abacus](https://camo.githubusercontent.com/abe08b740a4156153736f791393ec4da6619c4be73212e75769f52edacc0e2b5/68747470733a2f2f6261646765732e6769747465722e696d2f4a6f696e253230436861742e737667)](https://gitter.im/elliotwms/Abacus?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

PHP currency manipulation package from the future. Still in very early development.

Usage
-----

[](#usage)

Once Abacus has been [set up successfully](#installation), it can be used like so:

```
$abacus = new Abacus(1250.00);          // Create a new Abacus object. Defaults to USD
echo $abacus;                           // "1250.00"
echo $abacus->format();                 // "$1,250.00"
echo $abacus->value                     // 1250

$abacus->toCurrency("GBP");             // Convert USD to GBP

$abacus->add(20);                       // Addition
$abacus->add(10, "GBP");                // Addition of a value in another currency
$abacus->add(new Abacus(5, "GBP");      // Adding another Abacus object

$abacus->sub(20);                       // Subtraction
$abacus->sub(10, "GBP");                // Subtraction of a value in another currency
$abacus->sub(new Abacus(5, "GBP");      // Subtract another Abacus object
```

Installation
------------

[](#installation)

Install Abacus via [Composer](//getcomposer.org) by either including it in your composer.json file:

```
{
    "require": {
        "elliotwms/abacus": "0.1.*"
    }
}
```

Or by running:

```
composer require elliotwms/abacus dev-master
```

### Polling the API

[](#polling-the-api)

Abacus depends on data retrieved from the [Open Exchange Rates](https://openexchangerates.org/)API. In order to use Abacus fully, you must poll the API using your own API key. Abacus will look for an environment variable named `ABACUS_OPEN_EXCHANGE_KEY` and can be polled in several ways.

I recommend setting up a CRON service to poll the Open Exchange hourly in order to keep an up to date record of the currency exchange rates. At the time of writing, the free tier of the Open Exchange Rates API allows for 1,000 calls per month and there are 744 hours in a month so you're sorted. It would be fruitless to poll more than once an hour on the free tier as the information is updated hourly.

If you want more up-to-the-minute exchange rates, I highly recommend [signing up for a paid plan](//openexchangerates.org/signup)

#### Using the included script

[](#using-the-included-script)

Abacus includes a shell script to minimize the setup process.

You can call it like so (with absolute filepaths for your CRON service) from the root of your project directory:

```
php vendor/bin/abacus

```

By default it will use the `ABACUS_OPEN_EXCHANGE_KEY` environment variable, but if you need to specify it manually you can pass it as an argument:

```
php vendor/bin/abacus my_super_secret_api_key

```

#### Doing it manually

[](#doing-it-manually)

```
Currency::update();
```

Abacus will also accept an API key directly:

```
Currency::update('my_api_key');
```

Contributing
============

[](#contributing)

Abacus uses test driven development, which means that in order to write a feature, you need to write a test for that feature. You're going to need to do a few things to get this up and running:

- Install the development dependencies with `composer install`
- Set your `ABACUS_OPEN_EXCHANGE_KEY` as an environment variable. You can do this in a bash shell with:

```
export ABACUS_OPEN_EXCHANGE_KEY=your_abacus_api_key
echo $ABACUS_OPEN_EXCHANGE_KEY
```

- Poll the service with PHP to seed the exchange data:

```
php bin/abacus
```

You should see something similar to the following:

```
Polling OpenExchange
Successfully polled OpenExchange with environment variables

```

- Run PHPUnit. If something didn't pass then you may have not set up your exchange data correctly.

From here you can write tests and run PHPUnit to test them, and off you go!

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

2

Last Release

4098d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/344cef9c53ce2bba133b74d46805f5a4828edc711741a770047098e57767a8e6?d=identicon)[elliotwms](/maintainers/elliotwms)

---

Top Contributors

[![elliotwms](https://avatars.githubusercontent.com/u/4396779?v=4)](https://github.com/elliotwms "elliotwms (66 commits)")[![gitter-badger](https://avatars.githubusercontent.com/u/8518239?v=4)](https://github.com/gitter-badger "gitter-badger (1 commits)")

---

Tags

currencyabacus

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/elliotwms-abacus/health.svg)

```
[![Health](https://phpackages.com/badges/elliotwms-abacus/health.svg)](https://phpackages.com/packages/elliotwms-abacus)
```

###  Alternatives

[brick/money

Money and currency library

1.9k37.9M102](/packages/brick-money)[florianv/swap

Exchange rates library for PHP

1.3k6.4M16](/packages/florianv-swap)[cknow/laravel-money

Laravel Money

1.0k4.3M22](/packages/cknow-laravel-money)[akaunting/laravel-money

Currency formatting and conversion package for Laravel

7825.3M18](/packages/akaunting-laravel-money)[webpatser/laravel-countries

Modern Laravel Countries package providing ISO 3166-2, ISO 3166-3, currency, capital and more for all countries. Compatible with Laravel 11.x and 12.x.

8272.8M8](/packages/webpatser-laravel-countries)[kwn/number-to-words

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

4235.0M21](/packages/kwn-number-to-words)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
