php-units-of-measure/php-units-of-measure
A PHP library for converting between standard units of measure.
v2.2.0
3.9M downloads/mo
#2445 most downloaded on Packagist
PhpUnitsOfMeasure/php-units-of-measure
What this package is like to depend on
Last release 1 years ago
30 Apr 2025
Ships unpredictably
gaps range from 2 months to 8.8 years
Most releases are documented
notes for 10 of 12 stable releases
Nothing withdrawn
no release was ever pulled
13 years old
12 releases · first in 2013
0 releases in the last 12 months
see the full history below
Release timeline
12 releases · May 2013 to Apr 2025
2014
2016
2018
2020
2022
2024
2026
Releases
latest 12-
v2.2.030 Apr 2025Release notes
Open source →v2.2.0 (April 30th, 2025)
- Drop support of PHP < 7.4
- Add
isUnitDefined(),listAllUnits(),getOriginalValue(), andgetOriginalUnit()methods to the Physical Quantity parent class - Add new Power Physical Quantity
- Add Imperial Gallons to the Volume quantity
- Move to Github Actions, away from Travis CI
- Use Docker containers instead of Vagrant/VBox instances for dev environments
- Add local dev scripts for
lint,test, andshell, in./scripts/
Release notes
Open source →- Drop support of PHP < 7.4
- Add
isUnitDefined(),listAllUnits(),getOriginalValue(), andgetOriginalUnit()methods to the Physical Quantity parent class - Add new Power Physical Quantity
- Add Imperial Gallons to the Volume quantity
- Move to Github Actions, away from Travis CI
- Use Docker containers instead of Vagrant/VBox instances for dev environments
- Add local dev scripts for
lint,test, andshell, in./scripts/
-
v2.1.024 Jul 2016Release notes
Open source →- Added getUnitDefinitions() method to PhysicalQuantity classes, to get a raw list of UnitofMeasure objects defined on that quantity
- Added UPPERCASE templating support for autogenerated metric units to support names like MEGA_METERS, for example.
- New Quantity physical quantity, with
moleas the standard unit, to represent the Amount of Substance SI base quantity. - New SolidAngle physical quantity, with
steradianas the standard unit, to represent the solid angle quantity - Additional aliases for Area units
- Additional units for time: decade, century, and millenium
- Additional units for volume: teaspoon, tablespoon, gallon, quart, fluid ounce, and pint
-
v2.0.112 Dec 2015Release notes
Open source →- Migrated package from triplepoint/php-units-of-measure to php-units-of-measure/php-units-of-measure.
- New physical quantity: Energy
- New units of measure:
- Area: are and decare
- Length: nautical mile, mil, AU
- Mass: stone, also slightly changed definitions of lb and oz
- Time: yr, and jyr
- Velocity: km/h, ft/s, mph, knot
- Automated CI testing now includes HHVM and PHP 7
- Removed the heavy vagrant git submodule, it was a silly thing.
- Expanded the Readme for better contribution and installation instructions.
-
v2.0.014 Mar 2015Release notes
Open source →- Registered units of measure are now properties of PhysicalQuantity classes, and not individual instances of those classes. As such, registering a new unit with a given PhysicalQuantity will make that unit immediately available to all inntances of that class.
- PhysicalQuantity classes no longer define their units in their constructor, and instead have a new initialize() static method
- The previously-existing registerUnitOfMeasure() method on physical quantity objects has been replaced with a new static addUnit() method
- The HasSoUnitsTrait method addMissingSIPrefixedUnits is now static
- Added the toNativeUnit() method, to return values in their native unit of measure
- Added the isEquivalentQuantity() method, to support future situations where it's not obvious whether two physical quantities represent the same quantity type
- getSupportedUnits() is no longer available on physical quantities
- The PhysicalQuantity parent class is now named AbstractPhysicalQuantity
- Add a new DemonstrationTests test file, to demonstrate and test typical use cases
- All library exceptions extend from AbstractPhysicalQuantityException, making catching easier
- Added an interface for PhysicalQuantities, to support future work where not all physical quantity classes necessarily have the same parent
Release notes
Open source →- Registered units of measure are now properties of PhysicalQuantity classes, and not individual instances of those classes. As such, registering a new unit with a given PhysicalQuantity will make that unit immediately available to all inntances of that class.
- PhysicalQuantity classes no longer define their units in their constructor, and instead have a new initialize() static method
- The previously-existing registerUnitOfMeasure() method on physical quantity objects has been replaced with a new static addUnit() method
- The HasSoUnitsTrait method addMissingSIPrefixedUnits is now static
- Added the toNativeUnit() method, to return values in their native unit of measure
- Added the isEquivalentQuantity() method, to support future situations where it's not obvious whether two physical quantities represent the same quantity type
- getSupportedUnits() is no longer available on physical quantities
- The PhysicalQuantity parent class is now named AbstractPhysicalQuantity
- Add a new DemonstrationTests test file, to demonstrate and test typical use cases
- All library exceptions extend from AbstractPhysicalQuantityException, making catching easier
- Added an interface for PhysicalQuantities, to support future work where not all physical quantity classes necessarily have the same parent
- Registered units of measure are now properties of PhysicalQuantity classes, and not individual instances of those classes. As such, registering a new unit with a given PhysicalQuantity will make that unit immediately available to all inntances of that class.
-
v1.3.316 Mar 2015Release notes
Open source →- Loosened Composer requirement on PHP version to >=5.3.0 (was previously 5.3.5).
Release notes
Open source →- Loosened Composer requirement on PHP version to >=5.3.0 (was previously 5.3.5).
-
v1.3.124 Aug 2014Release notes
Open source →- Added information in the README about the new SI prefix units generation
-
v1.3.024 Aug 2014Release notes
Open source →- Add support for automatically generating metric-prefixed units from a single base unit
- Throw an exception on registering units of measure with names or aliases that collide with existing units on that quantity
- Disallow values that aren't numerical and unit names that aren't strings (ie, type checking)
- Add new method getSupportedUnits() to Physical Quantities
- Add new method getAliases() to Units of Measure
- Add arcminute and arcsecond as angle units
- Add all SI prefix units to meters, kilograms, seconds, amps, kelvin, candela, pascal, bar, radians, degrees, and arcseconds
-
v1.2.016 Aug 2014Release notes
Open source →- Drop support for PHP 5.3
- Moved to PSR-4 namespace convention
- Drop support for an array of names passed in the constructor as a way to specify aliases for UnitOfMeasure objects; addAlias() now required.
- Add UnitOfMeasure::nativeUnitFactory() and UnitOfMeasure::linearUnitFactory() convenience factory methods
- Add optional spelling for 'metres' and 'litres'
- Add Vagrant-based testing virtual machine, for convenience
-
v1.1.210 Feb 2014Release notes
Open source →- New units of measure on Area: hectares, international acres
- New units of measure on Temperature: Rankin, Delisle, Newton, Réaumur, Rømer
- Improved unit test coverage
-
v1.1.109 Jul 2013 -
v1.107 May 2013Nothing published for this version
-
v1.007 May 2013Nothing published for this version