idct-tech/php-decimal-io-dbal

Missing link between php-decimal.io and Doctrine.

Installs: 34

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/idct-tech/php-decimal-io-dbal

1.0 2021-06-23 23:16 UTC

This package is auto-updated.

Last update: 2025-09-24 08:19:20 UTC


README

The missing link between Doctrine and php-decimal.io.

Installation

You require at least PHP 8.0, decimal extension and php-decimal library (installed via composer).

To install this library just type:

composer require idct-tech/php-decimal-io-dbal

Then in your doctrine configuration be sure to set up the mapping: https://www.doctrine-project.org/projects/doctrine-orm/en/2.9/cookbook/custom-mapping-types.html

In Symfony 4+, 5+ you can set this up in your config/packages/doctrine.yaml:

doctrine:
    dbal:
        types:
            php_decimal_io:  IDCT\Dbal\PhpDecimalIoType\PhpDecimalIoType

Usage

In your field declarations use type php_decimal_io, for example:

    /**
     * @ORM\Column(type="php_decimal_io"))
     */
    private Decimal $totalStake;

Precision is set to 65 which means that maximum number of digits which can be stored is 65.