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 yesterday

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 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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

2123d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/57459f7326aae52d0691c0b3eb2bb90655add2bcb8b60dc0d76424127dc2128d?d=identicon)[amberovsky](/maintainers/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

[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58523.9M36](/packages/scienta-doctrine-json-functions)[damienharper/auditor-bundle

Integrate auditor library in your Symfony projects.

4542.8M](/packages/damienharper-auditor-bundle)[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[pixelfederation/doctrine-resettable-em-bundle

Symfony bundle for decorating default entity managers using a resettable decorator.

20113.5k](/packages/pixelfederation-doctrine-resettable-em-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.

1022.4k](/packages/rcsofttech-audit-trail-bundle)[ahmed-bhs/doctrine-doctor

Runtime analysis tool for Doctrine ORM integrated into Symfony Web Profiler. Unlike static linters, it analyzes actual query execution at runtime to detect performance bottlenecks, security vulnerabilities, and best practice violations during development with real execution context and data.

813.1k](/packages/ahmed-bhs-doctrine-doctor)

PHPackages © 2026

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