All Projects â†’ moneyphp â†’ Money

moneyphp / Money

Licence: mit
PHP implementation of Fowler's Money pattern.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to Money

react-local-currency
💵 💴Shows the price of your services in the customer's currency 💶 💷
Stars: ✭ 21 (-99.46%)
Mutual labels:  money, currency, currency-exchange-rates, currency-converter
Laravel Money
Currency formatting and conversion package for Laravel
Stars: ✭ 261 (-93.25%)
Mutual labels:  currency, currency-converter, money
currency-converter
💰 Easily convert between 32 currencies
Stars: ✭ 16 (-99.59%)
Mutual labels:  money, currency, currency-converter
php-currency-api
Standardized wrapper for popular currency rate APIs. Currently supports FixerIO, CurrencyLayer, Open Exchange Rates and Exchange Rates API.
Stars: ✭ 17 (-99.56%)
Mutual labels:  currency, currency-exchange-rates, currency-converter
javascript-forex-quotes
JavaScript Library for fetching realtime forex quotes.
Stars: ✭ 38 (-99.02%)
Mutual labels:  currency, currency-exchange-rates, currency-converter
historical-bank-ruby
A Ruby Bank that serves historical exchange rates
Stars: ✭ 14 (-99.64%)
Mutual labels:  currency, currency-exchange-rates, currency-converter
Money
A money and currency library for PHP
Stars: ✭ 855 (-77.9%)
Mutual labels:  currency, currency-converter, money
Android Money
Simple money and currency converter library for android.
Stars: ✭ 66 (-98.29%)
Mutual labels:  currency, currency-converter, money
Swap
💱 Currency exchange rates library
Stars: ✭ 1,195 (-69.11%)
Mutual labels:  currency, currency-converter, money
currency-api
Free Currency Exchange Rates API with 150+ Currencies & No Rate Limits
Stars: ✭ 507 (-86.89%)
Mutual labels:  currency, currency-exchange-rates, currency-converter
alfred-currency-conversion
Alfred 4 Workflow - See foreign exchange rates and currency conversion
Stars: ✭ 149 (-96.15%)
Mutual labels:  currency-exchange-rates, currency-converter
Jsr354 Api
JSR 354 - Money and Currency API
Stars: ✭ 262 (-93.23%)
Mutual labels:  currency, money
money-parser
Price and currency parsing utility
Stars: ✭ 26 (-99.33%)
Mutual labels:  money, currency
react-numeric
A react component for formatted number form fields
Stars: ✭ 30 (-99.22%)
Mutual labels:  money, currency
Laravel Swap
💵 Currency exchange rates for Laravel and Lumen
Stars: ✭ 296 (-92.35%)
Mutual labels:  currency, currency-converter
FinanceKit
FinanceKit is a Framework for iOS and Mac to build apps working with financial data, like money, currencies, stocks, portfolio, transactions and other concepts.
Stars: ✭ 15 (-99.61%)
Mutual labels:  money, currency
Guide-to-Swift-Numbers-Sample-Code
Xcode Playground Sample Code for the Flight School Guide to Swift Numbers
Stars: ✭ 92 (-97.62%)
Mutual labels:  money, currency
Narvalo.NET
Applied functional patterns for C#. Money and Currency types. MVP framework. (Obsolete)
Stars: ✭ 16 (-99.59%)
Mutual labels:  money, currency
money
Crystal shard for dealing with money and currency conversion
Stars: ✭ 26 (-99.33%)
Mutual labels:  money, currency
swift-currency
Type-safety and algorithms for working with money in Swift.
Stars: ✭ 88 (-97.72%)
Mutual labels:  money, currency

Money

Latest Version GitHub Workflow Status Total Downloads

Email

Money PHP

PHP library to make working with money safer, easier, and fun!

"If I had a dime for every time I've seen someone use FLOAT to store currency, I'd have $999.997634" -- Bill Karwin

In short: You shouldn't represent monetary values by a float. Wherever you need to represent money, use this Money value object. Since version 3.0 this library uses strings internally in order to support unlimited integers.

<?php

use Money\Money;

$fiveEur = Money::EUR(500);
$tenEur = $fiveEur->add($fiveEur);

list($part1, $part2, $part3) = $tenEur->allocate([1, 1, 1]);
assert($part1->equals(Money::EUR(334)));
assert($part2->equals(Money::EUR(333)));
assert($part3->equals(Money::EUR(333)));

The documentation is available at http://moneyphp.org

Requirements

This library requires the BCMath PHP extension. There might be additional dependencies for specific feature, e.g. the Swap exchange implementation, check the documentation for more information.

Version 4 requires PHP 8.0. For older version of PHP, use version 3 of this library.

Install

Via Composer

$ composer require moneyphp/money

Features

  • JSON Serialization
  • Big integer support utilizing different, transparent calculation logic upon availability (bcmath, gmp, plain php)
  • Money formatting (including intl formatter)
  • Currency repositories (ISO currencies included)
  • Money exchange (including Swap implementation)

Documentation

Please see the official documentation.

Testing

We try to follow BDD and TDD, as such we use both phpspec and phpunit to test this library.

$ composer test

Running the tests in Docker

Money requires a set of dependencies, so you might want to run it in Docker.

First, build the image locally:

$ docker build -t moneyphp .

Then run the tests:

$ docker run --rm -it -v $PWD:/app -w /app moneyphp vendor/bin/phpunit --exclude-group segmentation

Contributing

We would love to see you helping us to make this library better and better. Please keep in mind we do not use suffixes and prefixes in class names, so not CurrenciesInterface, but Currencies. Other than that, Style CI will help you using the same code style as we are using. Please provide tests when creating a PR and clear descriptions of bugs when filing issues.

Security

If you discover any security related issues, please contact us at [email protected].

License

The MIT License (MIT). Please see License File for more information.

Acknowledgements

This library is heavily inspired by Martin Fowler's Money pattern. A special remark goes to Mathias Verraes, without his contributions, in code and via his blog, this library would not be where it stands now.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].