padam87/money-bundle

Symfony bundle for https://github.com/moneyphp/money

Installs: 1 170

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 2

Forks: 3

Open Issues: 1

Type:symfony-bundle

v0.5.1 2022-03-10 21:11 UTC

This package is auto-updated.

Last update: 2024-04-14 02:02:53 UTC


README

Symfony bundle for https://github.com/moneyphp/money

As an opinionated bundle, this money bundle uses the following principles as it's main guide:

  • Storage is just as important as calculation.
  • Financial data should be held in SQL, so Doctrine ORM only implementation.
  • Money objects are Embeddables.
  • Amount should be stored in a human readable way in the database.
  • ISO money scale (eg smallest amount is 1 cent for EUR) is not viable for complex applications.

To achieve these, the following restrictions apply:

Installation

composer require padam87/money-bundle

Configuration (optional)

padam87_money:
    precision:            18
    scale:                2
    currencies:

        # Default:
        - EUR

Usage

Doctrine

    /**
     * @var Money
     *
     * @ORM\Embedded(class="Money\Money")
     */
    private $price;

Formatting

The bundle adds 2 services.

padam87_money.number_formatter - A simple \NumberFormatter object, with the current request's locale, and currency style.

Money\Formatter\IntlMoneyFormatter - Intl money formatter