Download the PHP package philiprehberger/php-money without Composer

On this page you can find all versions of the php package philiprehberger/php-money. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-money

PHP Money

Tests Latest Version on Packagist Last updated

Immutable Money value object with currency support, formatting, arithmetic, and Laravel Eloquent cast.

Requirements

Installation

Laravel

The package auto-discovers MoneyServiceProvider. No configuration is required.

Usage

Creating Money

Arithmetic

All arithmetic methods return new Money instances and leave the original unchanged.

Comparison

Allocation

Collection Operations

Rounding Modes

Currency Conversion

Min / Max

Formatting

Laravel Eloquent Cast

API

Money

Method Description Returns
Money::USD(int $amount) Create USD instance (and other static currency factories) Money
Money::of(int $amount, string $currency) Create instance for any currency code Money
Money::zero(string $currency) Create zero-value instance Money
Money::parse(string $value, string $currency) Parse a formatted string Money
Money::sum(Money $first, Money ...$rest) Sum all money values Money
Money::avg(Money $first, Money ...$rest) Average of all money values Money
Money::minimum(Money $first, Money ...$rest) Return the smallest value Money
Money::maximum(Money $first, Money ...$rest) Return the largest value Money
Money::min(Money ...$amounts) Return the smallest value Money
Money::max(Money ...$amounts) Return the largest value Money
->getAmount() Get amount in smallest unit int
->getCurrency() Get Currency instance Currency
->add(Money $other) Add two money values Money
->subtract(Money $other) Subtract two money values Money
->multiply(int\|float $factor, ?RoundingMode $mode) Multiply by a factor Money
->divide(int\|float $divisor, ?RoundingMode $mode) Divide by a divisor Money
->percentage(int\|float $percent) Calculate a percentage Money
->convertTo(Currency $target, float $rate) Convert to another currency Money
->allocate(int[] $ratios) Split proportionally without rounding loss Money[]
->allocateEqual(int $parts) Split equally (remainder to first parts) Money[]
->equals(Money $other) Check equality bool
->greaterThan(Money $other) Greater than comparison bool
->lessThan(Money $other) Less than comparison bool
->greaterThanOrEqual(Money $other) Greater than or equal comparison bool
->lessThanOrEqual(Money $other) Less than or equal comparison bool
->isZero() Check if amount is zero bool
->isPositive() Check if amount is positive bool
->isNegative() Check if amount is negative bool
->format(string $locale = 'en_US') Locale-aware formatted string string
->toArray() Serialise to array array

RoundingMode

Case Value Description
HALF_UP half_up Round half away from zero (default)
HALF_DOWN half_down Round half toward zero
HALF_EVEN half_even Banker's rounding
CEILING ceiling Round toward positive infinity
FLOOR floor Round toward negative infinity

Exceptions

Exception When thrown
CurrencyMismatchException Arithmetic or comparison between different currencies
InvalidAmountException Division by zero, unparseable string, empty/negative ratios
InvalidArgumentException Unknown currency code, empty currency code, invalid cast input

Development

Support

If you find this project useful:

Star the repo

🐛 Report issues

💡 Suggest features

❤️ Sponsor development

🌐 All Open Source Projects

💻 GitHub Profile

🔗 LinkedIn Profile

License

MIT


All versions of php-money with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-intl Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package philiprehberger/php-money contains the following files

Loading the files please wait ...