PHPackages                             wdandrewjames/unit-converter - 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. wdandrewjames/unit-converter

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wdandrewjames/unit-converter
============================

A simple unit converter library for PHP

1(5y ago)16MITPHP

Since Nov 6Pushed 5y ago1 watchersCompare

[ Source](https://github.com/wdandrewjames/unit-converter)[ Packagist](https://packagist.org/packages/wdandrewjames/unit-converter)[ Docs](https://artisanlabs.co.uk)[ RSS](/packages/wdandrewjames-unit-converter/feed)WikiDiscussions main Synced today

READMEChangelog (1)DependenciesVersions (2)Used By (0)

PHP Unit Converter
==================

[](#php-unit-converter)

Unit Converter is a PHP library for dealing with converting units.

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

[](#installation)

Use composer to install.

```
composer require wdandrewjames/unit-converter

```

Usage
-----

[](#usage)

Instantiate a new Converter Object, which requires an object which implements the ConverterTypeInterface. In this case we are using Mass class.

```
use Converter\Converter;
use Converter\ConversionTypes\Mass;

$converter = new Converter(new Mass);
```

Use the convert() method on the Converter object to set the value you wish to convert from. This method accepts 2 arguments:

$value: The value being converted from

$unit: The unit you being converted from

Once the convert() method has been run, you may then use the to() method. This method takes 1 argument:

$unit: The unit you being converted to

```
echo $converter->convert(1, 'kilogram')->to('gram');
// 1000
```

You can also run multiple conversions once convert() method has been run.

```
$converter->convert(1000, 'gram');

echo $converter->to('kilogram');
// 1
echo $converter->to('gram');
// 1000
echo $converter->to('pound');
// 2.2046244201838
echo $converter->to('milligram');
// 1000000
```

The getAvailableUnits() method will return an array of all available units for a particular conversion quantity.

```
use Converter\Converter;
use Converter\ConversionTypes\Mass;

$converter = new Converter(new Mass);
$converter->getAvailableUnits();
```

### Available Conversion Types

[](#available-conversion-types)

Length

Mass

Speed

Volume

License
-------

[](#license)

[MIT](https://choosealicense.com/licenses/mit/)

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

Unknown

Total

1

Last Release

2011d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b9e5d6107ee341879eeddc63a8878015e530a5b95fb8cfb473f1c3cb228f82a0?d=identicon)[ajr237](/maintainers/ajr237)

---

Top Contributors

[![wdandrewjames](https://avatars.githubusercontent.com/u/66685861?v=4)](https://github.com/wdandrewjames "wdandrewjames (5 commits)")

---

Tags

unitconverterphp unit converter

### Embed Badge

![Health badge](/badges/wdandrewjames-unit-converter/health.svg)

```
[![Health](https://phpackages.com/badges/wdandrewjames-unit-converter/health.svg)](https://phpackages.com/packages/wdandrewjames-unit-converter)
```

###  Alternatives

[mark-gerarts/auto-mapper-plus

An AutoMapper for PHP

5623.2M21](/packages/mark-gerarts-auto-mapper-plus)[iamcal/php-emoji

This is a PHP library for dealing with Emoji, allowing you to convert between various native formats and displaying them using HTML.

1.3k481.1k](/packages/iamcal-php-emoji)[matthiasmullie/path-converter

Relative path converter

10229.6M7](/packages/matthiasmullie-path-converter)[ncjoes/office-converter

PHP Wrapper for LibreOffice

2431.2M4](/packages/ncjoes-office-converter)[henck/rtf-to-html

RTF to HTML converter in PHP

108785.6k1](/packages/henck-rtf-to-html)[php-unit-conversion/php-unit-conversion

A fully PSR-4 compatible PHP library for converting between standard units of measure.

681.2M1](/packages/php-unit-conversion-php-unit-conversion)

PHPackages © 2026

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