PHPackages                             midnightluke/php-units-of-measure-bundle - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. midnightluke/php-units-of-measure-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

midnightluke/php-units-of-measure-bundle
========================================

Symfony bundle wrapper for the PHP Units of Measure library with useful doctrine and form types.

1.0.x-dev(6y ago)21.3k3[4 issues](https://github.com/midnightLuke/php-units-of-measure-bundle/issues)1MITPHPPHP ^5.5.9 || ^7.0CI failing

Since Jun 6Pushed 6y ago1 watchersCompare

[ Source](https://github.com/midnightLuke/php-units-of-measure-bundle)[ Packagist](https://packagist.org/packages/midnightluke/php-units-of-measure-bundle)[ RSS](/packages/midnightluke-php-units-of-measure-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (7)Versions (10)Used By (1)

PHP Units Of Measure Bundle
===========================

[](#php-units-of-measure-bundle)

[![Build Status](https://camo.githubusercontent.com/2dfa6c657b555eaabb19fe0cfe4337f5f9f4e3582cd443db1fe97d758ddfce62/68747470733a2f2f7472617669732d63692e6f72672f6d69646e696768744c756b652f7068702d756e6974732d6f662d6d6561737572652d62756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/midnightLuke/php-units-of-measure-bundle)[![Coverage Status](https://camo.githubusercontent.com/9409b9f0cf48f79b4d41bba102d6cef35336dd6f067b44202a01deb120877980/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d69646e696768744c756b652f7068702d756e6974732d6f662d6d6561737572652d62756e646c652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/midnightLuke/php-units-of-measure-bundle?branch=master)

Provides useful Doctrine and Form types for working with the [PHP Units of Measure](https://github.com/PhpUnitsOfMeasure/php-units-of-measure)Library.

Installation
------------

[](#installation)

Install this bundle using composer:

```
composer require midnightluke/php-units-of-measure-bundle:dev-master

```

Add it to your application kernel (AppKernel.php):

```
class AppKernel extends Kernel
{
    // [...]
    public function registerBundles()
    {
        $bundles = [
            // [...]
            new MidnightLuke\PhpUnitsOfMeasureBundle\MidnightLukePhpUnitsOfMeasureBundle(),
        ];
    }
    // [...]
}
```

Add the form types you need to doctrine in config.yml:

```
doctrine:
    dbal:
        types:
            acceleration:         MidnightLuke\PhpUnitsOfMeasureBundle\Doctrine\Types\AccelerationType
            angle:                MidnightLuke\PhpUnitsOfMeasureBundle\Doctrine\Types\AngleType
            area:                 MidnightLuke\PhpUnitsOfMeasureBundle\Doctrine\Types\AreaType
            electric_current:     MidnightLuke\PhpUnitsOfMeasureBundle\Doctrine\Types\ElectricCurrentType
            energy:               MidnightLuke\PhpUnitsOfMeasureBundle\Doctrine\Types\EnergyType
            length:               MidnightLuke\PhpUnitsOfMeasureBundle\Doctrine\Types\LengthType
            luminous_intensity:   MidnightLuke\PhpUnitsOfMeasureBundle\Doctrine\Types\LuminousIntensityType
            mass:                 MidnightLuke\PhpUnitsOfMeasureBundle\Doctrine\Types\MassType
            pressure:             MidnightLuke\PhpUnitsOfMeasureBundle\Doctrine\Types\PressureType
            quantity:             MidnightLuke\PhpUnitsOfMeasureBundle\Doctrine\Types\QuantityType
            solid_angle:          MidnightLuke\PhpUnitsOfMeasureBundle\Doctrine\Types\SolidAngleType
            temperature:          MidnightLuke\PhpUnitsOfMeasureBundle\Doctrine\Types\TemperatureType
            uom_time:             MidnightLuke\PhpUnitsOfMeasureBundle\Doctrine\Types\TimeType
            velocity:             MidnightLuke\PhpUnitsOfMeasureBundle\Doctrine\Types\VelocityType
            volume:               MidnightLuke\PhpUnitsOfMeasureBundle\Doctrine\Types\VolumeType
```

Configuration
-------------

[](#configuration)

This bundle comes with configuration that allows you to specify the "default" unit for each unit of measure form type. This can be configured in your app's config.yml file like so:

```
units_of_measure:
    base_units:
        acceleration:         m/s^2
        angle:                rad
        area:                 m^2
        electric_current:     A
        energy:               J
        length:               m
        luminous_intensity:   cd
        mass:                 kg
        pressure:             Pa
        quantity:             mol
        solid_angle:          sr
        temperature:          K
        uom_time:             s
        velocity:             m/s
        volume:               m^3
```

Note that this is optional and the defaults above will be used otherwise.

Use
---

[](#use)

This module allows you to use native PhysicalQuantity types in Doctrine and on forms.

### Doctrine Use

[](#doctrine-use)

```
class Person
{
    // [...]
    /**
     * @ORM\Column(type="length")
     * @var Length
     */
    private $height;
    // [...]
}
```

### Form Use

[](#form-use)

```
$form = $this->createFormBuilder()
    ->add('length', LengthType::class)
    ->add('mass', MassType::class)
    ->add('save', SubmitType::class, array('label' => 'Create Post'))
    ->getForm();
```

About
-----

[](#about)

### Submitting bugs and feature requests

[](#submitting-bugs-and-feature-requests)

Bugs and feature request are tracked on [GitHub](https://github.com/midnightLuke/php-units-of-measure-bundle/issues).

### Author

[](#author)

Luke Bainbridge -

### License

[](#license)

PHP Units Of Measure Bundle is licensed under the MIT License - see the LICENSE file for details.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity50

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 ~171 days

Recently: every ~229 days

Total

7

Last Release

2236d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/022eea08a0f5a1c84ef7930c8b03b4523f0ca47cfb2a813a74d45ebfaf266f3e?d=identicon)[midnightLuke](/maintainers/midnightLuke)

---

Top Contributors

[![midnightLuke](https://avatars.githubusercontent.com/u/3444018?v=4)](https://github.com/midnightLuke "midnightLuke (67 commits)")

---

Tags

symfony-bundlesymfony2symfony3units-of-measure

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/midnightluke-php-units-of-measure-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/midnightluke-php-units-of-measure-bundle/health.svg)](https://phpackages.com/packages/midnightluke-php-units-of-measure-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[wallabag/wallabag

open source self hostable read-it-later web application

12.6k2.2k](/packages/wallabag-wallabag)[netgen/layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.

3689.4k10](/packages/netgen-layouts-core)[jbtronics/settings-bundle

A symfony bundle to easily create typesafe, user-configurable settings for symfony applications

9546.7k2](/packages/jbtronics-settings-bundle)[pixelopen/cloudflare-turnstile-bundle

A simple package to help integrate Cloudflare Turnstile on Symfony.

31205.8k3](/packages/pixelopen-cloudflare-turnstile-bundle)[netgen/content-browser

Netgen Content Browser is a Symfony bundle that provides an interface which selects items from any kind of backend and returns the IDs of selected items back to the calling code.

14112.1k8](/packages/netgen-content-browser)

PHPackages © 2026

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