PHPackages                             amberovsky/currency-doctrine - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. amberovsky/currency-doctrine

ActiveLibrary[Database &amp; ORM](/categories/database)

amberovsky/currency-doctrine
============================

Allow the use of amberovsky/currency as a Doctrine field type.

v0.3(5y ago)08BSD-3-ClausePHPPHP ^7.4CI failing

Since Jul 5Pushed 5y ago1 watchersCompare

[ Source](https://github.com/amberovsky/currency-doctrine)[ Packagist](https://packagist.org/packages/amberovsky/currency-doctrine)[ RSS](/packages/amberovsky-currency-doctrine/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (3)Dependencies (5)Versions (5)Used By (0)

amberovsky/currency-doctrine
============================

[](#amberovskycurrency-doctrine)

The amberovsky/currency-doctrine package provides the ability to use [amberovsky/currency](https://github.com/amberovsky/currency) as a [Doctrine field type](https://www.doctrine-project.org/projects/doctrine-dbal/en/2.10/reference/types.html).

Examples
--------

[](#examples)

### Configuration

[](#configuration)

It requires CurrencyFactory to be injected in via CurrencyType::setCurrencyFactory method. Use your current DI mechanism to do that.

To configure Doctrine to use amberovsky/currency as a field type, you'll need to set up the following in your bootstrap:

```
use Doctrine\DBAL\Types\Type;
use Amberovsky\Money\Currency\Doctrine\CurrencyType;
use Amberovsky\Money\Currency\CurrencyFactory;

$currencyFactory = ...; // Get CurrencyFactory instance somehow

if (!Type::hasType(CurrencyType::NAME)) {
    Type::addType(CurrencyType::NAME, CurrencyType::class);
    /** @var CurrencyType $currencyType */
    $currencyType = Type::getType(CurrencyType::NAME);
    $currencyType->setCurrencyFactory($currencyFactory);
}
```

#### Symfony

[](#symfony)

Add this to your `Kernel.php`:

```
    /**
     * @inheritDoc
     */
    protected function initializeContainer() {
        parent::initializeContainer();

        if (!Type::hasType(CurrencyType::NAME)) {
            Type::addType(CurrencyType::NAME, CurrencyType::class);
            /** @var CurrencyType $currencyType */
            $currencyType = Type::getType(CurrencyType::NAME);
            $currencyType->setCurrencyFactory($this->container->get(CurrencyFactory::class));
        }
    }
```

### Usage

[](#usage)

Then, in your models, you may annotate properties by setting the `@Column` type to `Currency`. Doctrine will handle the rest.

```
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="invoices")
 */
class Invoice
{
    /**
     * @ORM\Column(type="Currency")
     */
    private Currency $currency;

    public function getCurrency(): Currency {
        return $this->currency;
    }
}
```

### How to contribute

[](#how-to-contribute)

Please fork this repo and create a PR. Make sure you run tests before submitting yout PR:

```
make phpstan
make psalm
make phpspec
```

### License

[](#license)

Copyright (C) 2020 Anton Zagorskii, BSD-3-Clause license, See [license file](/LICENSE.txt) for details

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~7 days

Total

3

Last Release

2173d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/477339?v=4)[amberovsky](/maintainers/amberovsky)[@amberovsky](https://github.com/amberovsky)

---

Top Contributors

[![amberovsky](https://avatars.githubusercontent.com/u/477339?v=4)](https://github.com/amberovsky "amberovsky (2 commits)")

###  Code Quality

Static AnalysisPHPStan, Psalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/amberovsky-currency-doctrine/health.svg)

```
[![Health](https://phpackages.com/badges/amberovsky-currency-doctrine/health.svg)](https://phpackages.com/packages/amberovsky-currency-doctrine)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M387](/packages/easycorp-easyadmin-bundle)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[kimai/kimai

Kimai - Time Tracking

4.8k9.0k1](/packages/kimai-kimai)[api-platform/doctrine-orm

Doctrine ORM bridge

294.4M90](/packages/api-platform-doctrine-orm)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k12](/packages/2lenet-crudit-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
