Download the PHP package leancaptain/lara-money without Composer

On this page you can find all versions of the php package leancaptain/lara-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 lara-money

Lara Money

A thin Laravel integration for leancaptain/money.

leancaptain/lara-money brings the framework-agnostic Money value object into Laravel with Eloquent casting, container integration, configurable defaults, and support for application-defined currencies.

The core money implementation remains in leancaptain/money. This package only provides the Laravel integration layer.

Requirements

Installation

Install the package via Composer:

The service provider is discovered automatically by Laravel.

No configuration needs to be published for the package to work.

Configuration

The package provides a sensible default configuration:

The default currency is used whenever a money cast does not specify a currency attribute.

The default rounding mode is used when monetary input needs to be parsed through the configured MoneyFactory.

Publishing the configuration

Publishing is optional.

If you want to customize the package configuration:

This publishes:

MoneyFactory

The package registers LeanCaptain\Money\MoneyFactory as a singleton in Laravel's service container.

You can resolve it normally:

The factory uses the currency and rounding mode configured in config/money.php.

Constructor injection works as expected:

Eloquent Money Cast

MoneyCast stores monetary values as integer minor units while exposing them as immutable Money value objects in your application.

For a currency with two minor-unit decimal places:

No floating-point representation is used for monetary storage or parsing.

Currency resolution

MoneyCast resolves the currency for a money attribute using a three-layer strategy, checked in this order:

  1. Explicit currency attribute — A column name passed to the cast constructor.
  2. Auto-detected currency column — A column named currency on the model, used automatically.
  3. Application default — The default currency from config('money.php').

The first match wins. This means a model with a currency column will use it automatically without any explicit configuration.

Using the default currency

If your model does not have a currency column and does not need a per-record currency, use the cast directly:

If the database contains:

and the configured currency is USD, reading:

returns a Money representing:

No currency column is required.

This is useful for applications or models that operate in a single known currency.

Auto-detecting a currency column

If your model has a column named currency, MoneyCast detects it automatically:

Given:

the cast returns a Money using Currency::EUR without any explicit currency attribute configuration.

This works because MoneyCast checks for the presence of a currency key in the model's attributes and uses it when no explicit attribute is specified.

Explicit currency attribute

For multi-currency models where the column is not named currency, pass the attribute name to the cast:

For example:

the cast returns a Money using Currency::EUR.

When a currency attribute is explicitly configured, it must contain a valid currency code. The cast does not silently fall back to the application's default currency when the explicit currency is missing or invalid.

Currency resolution flow

Assigning monetary values

The cast accepts:

Decimal strings

For a two-decimal currency, the database stores:

Integers

Integers follow the semantics of leancaptain/money and represent major units:

For a two-decimal currency, this stores:

If you need to work explicitly with minor units, construct a Money value first:

Money values

You can assign a Money object directly:

The cast persists its integer minor-unit representation.

Null

Nullable monetary attributes remain nullable:

is stored as:

null is not converted to zero money.

Floats

Floating-point monetary input is intentionally not supported:

Use a decimal string instead:

This preserves the strict monetary semantics of leancaptain/money and avoids floating-point ambiguity.

Currency safety

The cast does not perform currency conversion.

If a model uses the default currency, assigning a Money object with another currency is rejected.

For example, if the configured currency is BDT:

is invalid.

Likewise, for a multi-currency model:

assigning EUR money is rejected rather than silently changing the currency or treating EUR minor units as USD.

Currency conversion and foreign-exchange behavior are intentionally outside the scope of this package.

Custom currencies

leancaptain/money supports application-defined currencies through CurrencyContract.

lara-money preserves that extensibility.

For a single/default custom currency, configure any implementation of:

as the application's default currency.

For multi-currency models using stored currency codes, lara-money provides a CurrencyResolver extension point.

The default resolver supports the currencies built into leancaptain/money.

If your application stores additional currencies, provide your own resolver:

Then replace the default binding in your application's service provider:

This allows applications to define their own currency domain without requiring changes to either leancaptain/money or leancaptain/lara-money.

Built-in currencies

The built-in currencies come from leancaptain/money:

The built-in list is deliberately curated.

Applications that need additional currencies can implement CurrencyContract rather than requiring the core package to maintain an exhaustive currency catalog.

Rounding

Rounding behavior comes directly from leancaptain/money.

Supported modes include:

The default is:

This package does not introduce separate Laravel-specific rounding semantics.

Design Philosophy

lara-money is intentionally a thin adapter.

The dependency direction is:

The core package remains completely framework-agnostic.

This package aims to:

For the underlying Money API, arithmetic, comparisons, rounding behavior, exceptions, and currency contracts, see leancaptain/money.

Testing

Run the package test suite with:

License

Lara Money is open-source software licensed under the MIT License.


All versions of lara-money with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
leancaptain/money Version ^0.0.4
illuminate/database Version ^13.0
illuminate/support Version ^13.0
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 leancaptain/lara-money contains the following files

Loading the files please wait ...