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

ActiveLibrary

skoyah/unit-converter
=====================

A simple tool for converting units of measurement.

v1.2(4y ago)131.8k↓100%8[1 issues](https://github.com/skoyah/unit-converter/issues)MITPHPPHP ^7.1CI failing

Since Oct 28Pushed 4y ago1 watchersCompare

[ Source](https://github.com/skoyah/unit-converter)[ Packagist](https://packagist.org/packages/skoyah/unit-converter)[ RSS](/packages/skoyah-unit-converter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (7)Used By (0)

Unit Converter
==============

[](#unit-converter)

Unit Converter is a PHP library that makes unit converting a fairly simple an intuitive process.

[![Build Status](https://camo.githubusercontent.com/a1cd677da37907f072940b7c15142b3888305c6b53a8d0b507e9cce1cd78e82f/68747470733a2f2f7472617669732d63692e6f72672f736b6f7961682f756e69742d636f6e7665727465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/skoyah/unit-converter)[![Latest Stable Version](https://camo.githubusercontent.com/f6370cc0795c5c824a549c6acdd7602e640665114772d07d0cf017517efa87c1/68747470733a2f2f706f7365722e707567782e6f72672f736b6f7961682f756e69742d636f6e7665727465722f762f737461626c65)](https://packagist.org/packages/skoyah/unit-converter)[![License](https://camo.githubusercontent.com/2d4583f142efb67af9abc4d2b2769a59e4f6cac1a80b8ad23a39dc8b004be245/68747470733a2f2f706f7365722e707567782e6f72672f736b6f7961682f756e69742d636f6e7665727465722f6c6963656e7365)](https://packagist.org/packages/skoyah/unit-converter)[![StyleCI](https://camo.githubusercontent.com/0be49bdd8a96ae440c5964b3c02f34f520de88324499213b6ae1ad4a512499ba/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3135343338323632312f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/154382621)

---

Table of Contents
-----------------

[](#table-of-contents)

1. [Installation](#installation)
2. [Basic Usage](#basic-usage)
3. [Support](#support)
4. [Configuration](#configuration)
5. [Code of Conduct](#code-of-conduct)
6. [License](#license)

---

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

[](#installation)

```
$ composer require skoyah/unit-converter
```

Basic Usage
-----------

[](#basic-usage)

### Namespacing

[](#namespacing)

The Unit Converter library is under `Skoyah\Converter` namespace.

Once you have installed the Unit Converter library, converting from one unit of measurement to another is really simple.

First, create a new instance of the desired type and import the related class. The instance needs to accept two parameters - 1) a boolean for the quantity, and 2) a string for the unit of measurement.

Next, all you need is to call a `to()` method and pass in the parameter for the convertion.

### Example conversion:

[](#example-conversion)

```
use Skoyah\Converter\Mass;

$mass = new Mass(1, 'kg');
echo $mass->to('pounds'); // '2.20462262'
```

Alternatively, you can convert using the unit abbreviation as a parameter:

```
echo $mass->to('lbs'); // '2.20462262'
```

The `to()` method has also an optional parameter tor defining how many decimal units should be displayed for the given convertion.

```
echo $mass->to('lbs', 2); // '2.20'
```

Support
-------

[](#support)

Currently, the Unit Converter supports the following types:

- [Mass](#mass-units)
- [Temperature](#temperature-units)
- [Length](#length-units)
- [Pressure](#pressure-units)
- [Area](#area-units)
- [Volume](#volume-units) - ***New***

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

[](#configuration)

During instantiation or convertion, you have two options for defining the unit to be used.

There is a longform and a short-hand word available for each unit of measure.

For consistency, it is **recommended** to use lowercase letters, but if you prefer you can use uppercase letters since during instantiation and/or convertion, the unit of measure will be parsed and formatted to lowercase characters.

### Mass units

[](#mass-units)

longshort*tonnes**t**kilograms**kg**grams**g**milligrams**mg**pounds**lbs**onces**oz*### Temperature units

[](#temperature-units)

longshort*kelvin**k**celsius**c**fahrenheit**f*### Length units

[](#length-units)

longshort*kilometers**km**meters**m**decimeters**dm**centimeters**cm**millimeters**mm**inches**in**feet**ft**yards**yd**miles**mi**nautical miles**nmi*### Pressure units

[](#pressure-units)

longshort*bars**bar**millibars**mbar**kilopascals**kpa**pascals**pa**atmospheres**atm*### Area units

[](#area-units)

longshort*square kilometers**km2**square meters**m2**square centimeters**cm2**square millimeters**mm2**square inches**in2**square feet**ft2**square yards**yd2*### Volume units

[](#volume-units)

longshort*cubic millimeters**mm3**cubic centimeter**cm3**cubic decimeter**dm3**cubic meter**m3**cubic dekameter**dam3**cubic hectometer**hm3**cubic kilometer**km3*Code of Conduct
---------------

[](#code-of-conduct)

In order to ensure that the community is welcoming to all, please review and abide by the [Code of Conduct](https://github.com/skoyah/unit-converter/blob/master/CODE_OF_CONDUCT.md).

License
-------

[](#license)

Unit Converter is released under the MIT Licence. Read the [license](https://github.com/skoyah/unit-converter/blob/master/LICENSE.md) file for more details.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 96.2% 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 ~245 days

Recently: every ~306 days

Total

6

Last Release

1526d ago

Major Versions

v0.2 → v1.02018-11-04

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/36083448?v=4)[João Santos](/maintainers/skoyah)[@skoyah](https://github.com/skoyah)

---

Top Contributors

[![skoyah](https://avatars.githubusercontent.com/u/36083448?v=4)](https://github.com/skoyah "skoyah (51 commits)")[![angelochillemix](https://avatars.githubusercontent.com/u/13917784?v=4)](https://github.com/angelochillemix "angelochillemix (1 commits)")[![nunomaduro](https://avatars.githubusercontent.com/u/5457236?v=4)](https://github.com/nunomaduro "nunomaduro (1 commits)")

---

Tags

convertermeasurementsphpphp-libraryunit-converterphpconverterunit-converter

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[goetas-webservices/xsd2php

Convert XSD (XML Schema) definitions into PHP classes and JMS metadata

2411.6M37](/packages/goetas-webservices-xsd2php)[sbsaga/toon

🧠 TOON for Laravel — a compact, human-readable, and token-efficient data format for AI prompts &amp; LLM contexts. Perfect for ChatGPT, Gemini, Claude, Mistral, and OpenAI integrations (JSON ⇄ TOON).

6115.6k](/packages/sbsaga-toon)[goetas/xsd2php-runtime

Convert XSD (XML Schema) definitions into PHP classes

493.3k](/packages/goetas-xsd2php-runtime)

PHPackages © 2026

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