Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on May 9, 2024 via composer

moneyphp/money v4.4.0

PHP implementation of Fowler's Money pattern
Package summary
Share
0
issues
1
license
1
MIT
Package created
21 Oct 2016
Version published
24 Jan 2024
Maintainers
2
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
moneyphp/money@v4.4.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of moneyphp/money 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does moneyphp/money do?

MoneyPHP/Money is a PHP library that provides a practical and safe way to handle monetary values. Built around Martin Fowler's Money pattern, this library substitutes the potentially error-inducing method of storing currency as a float, and instead employs a value object - the Money. It uses strings internally to represent monetary values, supporting unlimited integers. This approach ensures that you can handle financial transactions in your PHP applications more accurately and dependably. The library also supports JSON serialization, big integer utilization, money formatting, including intl formatter, currency repositories including ISO currencies, and money exchange features which includes the Swap implementation.

How do you use moneyphp/money?

To use MoneyPHP/Money in your application, you first need to install it via composer. Run the command composer require moneyphp/money in your terminal within your project's directory. Once the library is installed, you can use it in your PHP code like in the example below:

<?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)));

In this example, the Money value object is used to handle addition and allocation of monetary values. You need to initialize the object with a currency and an amount (here, €5 is represented as 500 cents to avoid floats). Then you can use the add method to add monetary values. MoneyPHP also allows you to allocate money easily by dividing it into proportions without losing a single cent due to rounding errors.

Where are the moneyphp/money docs?

The comprehensive documentation for the MoneyPHP/Money library is available on their official website. The documentation provides detailed usage guides and extensive examples covering all of the features, from basic money operations to advanced features like money formatting and currency conversions.