brick / money

A money and currency library for PHP
MIT License
1.65k stars 102 forks source link

What is pros/cons in comparison with moneyphp/money #28

Closed Insolita closed 4 years ago

Insolita commented 4 years ago

What is pros/cons in comparison with https://github.com/moneyphp/money ?

IP-Developer commented 4 years ago

+1

toonvandenbos commented 4 years ago

+1

kohlerdominik commented 4 years ago

We started with moneyphp and we switched to brick/money, as, in my opinion, the design of brick/money is more flexible.

We use money without currency (Users can define a Project-wide currency, and then use this currency throughout the Project). So, actually currency is only handled when we show data to the User. But for a lot of calculations, storing in DB, etc, we still need to work with arbitrary numbers, and brick/money basing on brick/math makes this so easy.

BenMorel commented 4 years ago

Here is a non-exhaustive list of differences I compiled. I might be wrong about some of the points, if so please feel free to correct me, and I'll update this post.

OTOH, moneyphp supports the following features that brick/money doesn't:

toonvandenbos commented 4 years ago

Great summary @BenMorel. I'm considering moving my compound prices library to brick/money. Thank you!

hopeseekr commented 4 years ago

Compare to my project https://github.com/phpexpertsinc/MoneyType. It looks extremely similar.

https://github.com/brick/math/blob/master/src/Internal/Calculator/BcMathCalculator.php vs https://github.com/phpexpertsinc/MoneyType/blob/master/src/Internal/BCMathCalcStrategy.php

It's almost 1:1, including your using "Internal" direcotry and strategy pattern.

The MAJOR difference is that my project's only responsibilities are math manipulation and retrieval of currencies to X decimal places, while you'rs does a lot more of currency conversion, multiple currencies, etc.

that-guy-iain commented 4 years ago

@BenMorel I think you should add your comment to the readme since this will be a very common question and I personally didn't even think to look in the issues for the answer and only found this after being directed here.

BenMorel commented 4 years ago

@hopeseekr Thanks for the link, it's always interesting to see how others solve the same problem! I think the major difference between MoneyType and brick/money is that brick/money will by default have a scale that's per-currency (2 for EUR, USD etc.) and complain if you attempt to perform calculations that result in more decimal digits than configured (but provides Contexts to customize this, and RationalMoney to never round); this was a big requirement when creating this library, to ensure that you always handle rounding where necessary, or get an exception.

@iaicam The primary aim of this library is not to be a competitor to moneyphp, so I won't make a paragraph there highlighting the differences. However, you're right that this is becoming a frequently asked question, so I will probably add a link to this issue, and try to keep it up to date! 👍

BenMorel commented 4 years ago

A link to this issue has been added to the README.