PHPackages                             devsquared/unitconvert-laravel - 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. devsquared/unitconvert-laravel

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

devsquared/unitconvert-laravel
==============================

UnitConvert API Wrapper for Laravel

0.2.2(8y ago)1987MITPHPPHP ^7.0

Since Mar 6Pushed 8y ago1 watchersCompare

[ Source](https://github.com/Dev-Squared/unitconvert-laravel)[ Packagist](https://packagist.org/packages/devsquared/unitconvert-laravel)[ Docs](https://unitconvert.io)[ RSS](/packages/devsquared-unitconvert-laravel/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (4)Dependencies (2)Versions (4)Used By (0)

Convert/Compare Units of Measurement in Laravel
===============================================

[](#convertcompare-units-of-measurement-in-laravel)

[![Latest Version](https://camo.githubusercontent.com/b680a0361152dc11f0408e425fda26b2c99a9c03400a4700b31c928dc7150fda/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f4465762d537175617265642f756e6974636f6e766572742d6c61726176656c2e737667)](https://github.com/Dev-Squared/unitconvert-laravel/releases)[![GitHub license](https://camo.githubusercontent.com/acaa71b8235ca6e062914c841927773b45233376614c4383fbf0cd976485f6c3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f4465762d537175617265642f756e6974636f6e766572742d6c61726176656c2e737667)](https://github.com/Dev-Squared/unitconvert-laravel/blob/master/LICENSE.md)

With the UnitConvert.io wrapper for Laravel, you can quickly and easily compare and convert units of measurement programmatically.

This package was created and developer by DevSquared - a consultant and development agency located in Pittsburg, KS, USA. [Check out our website](https://dev-squared.com/) to learn more information about us.

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

[](#installation)

UnitConvert requires an API key to use this wrapper. You can [sign up for a free account today](https://unitconvert.io) and get started. This package can be installed through Composer.

`composer require devsquared/unitconvert-laravel`

In Laravel 5.5 and above, the package will autoregister the provider and the alias. For Laravel 5.4 and below, you must install the provider and the alias.

```
// config/app.php
'providers' => [
    ...
    DevSquared\UnitConvert\UnitConvertProvider::class,
    ...
];

'aliases' => [
    ...
    'UnitConvert' => DevSquared\UnitConvert\UnitConvertFacade::class,
    ...
];

```

Next, you will need to add your API key to the config. You can add it to your `.env` file as

`UNITCONVERT_API_KEY=`

Optionally, you can publish the config file of this package with this command:

`php artisan vendor:publish --provider="DevSquared\UnitConvert\UnitConvertServiceProvider"`

Usage
-----

[](#usage)

The UnitConvert database contains variants as people use the system. Commonly misspellings, abbreviations, and full words are all excepted strings in addition to the measurement value. Below is an example of how to compare and convert a unit of measurement(s).

```
use UnitConvert;

// Get Information for a Unit of Measurement
$response = UnitConvert::getMeasurementInfo('20 miles');
$response->getSuccess(); // Returns true
$response->getError(); // Returns the response error message, if success is false
$response->getAmount(); // Returns 20
$response->getUnit(); // Returns "Miles"
$response->getDisplay(); // Returns "20 Miles"
$response->getCategory(); // Returns "Length"
$response->getVariants(); // Returns ["Mile","Miles","mi"]
$response->getConvertableTo(); // Returns ["Centimeters","Millimeters","Meters","Inches","Feet","Yards","Miles","Decimeters","Kilometers","Astronomical Units","Light Years","Parsecs","Nautical Miles"]

// Comparing a Measurement
$response = UnitConvert::compare('10mg', '==', '10 pounds');
$response->getSuccess(); // Returns true
$response->getError(); // Returns the response error message, if success is false
$response->getResult(); // Returns false

// Converting a Measurement
$response = UnitConvert::convert('20 miles', 'kilometers');
$response->getSuccess(); // Returns true
$response->getError(); // Returns the response error message, if success is false
$response->getAmount(); // Returns 32.1868
$response->getUnit(); // Returns "Kilometers"
$response->getDisplay(); // Returns "32.18680 Kilometers"

```

Here is an example use case for the `convert` function:

```
$response = UnitConvert::convert('20 miles', 'gallons');
if ($response->getSuccess() == false) {
    return $response->getError();
}

return $response->getDisplay();

```

Changelog
---------

[](#changelog)

Please see the changelog for more information on what has changed recently.

Using this? Let us know!
------------------------

[](#using-this-let-us-know)

We really enjoy seeing our work being used in production environments. If you decide to implement this wrapper, feel free to let us know and share your work. You can send us an email on our website:

License
-------

[](#license)

The MIT License (MIT). Please see the [License File](LICENSE.md) for more information.

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

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

Total

3

Last Release

3038d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1386739f352f9e3e7c44796bde00203c877d8323d6f835705b154fa30a05b102?d=identicon)[Failcookie](/maintainers/Failcookie)

---

Tags

laravelunit-conversionunitconvertconvert measurements

### Embed Badge

![Health badge](/badges/devsquared-unitconvert-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/devsquared-unitconvert-laravel/health.svg)](https://phpackages.com/packages/devsquared-unitconvert-laravel)
```

###  Alternatives

[statamic/cms

The Statamic CMS Core Package

4.8k3.6M932](/packages/statamic-cms)[backpack/crud

Quickly build admin interfaces using Laravel, Bootstrap and JavaScript.

3.4k3.7M220](/packages/backpack-crud)[grumpydictator/firefly-iii

Firefly III: a personal finances manager.

23.8k69.4k](/packages/grumpydictator-firefly-iii)[unopim/unopim

UnoPim Laravel PIM

10.5k2.2k](/packages/unopim-unopim)[backpack/basset

Dead-simple way to load CSS or JS assets only once per page, when using Laravel 10+.

206971.5k11](/packages/backpack-basset)[firefly-iii/data-importer

Firefly III Data Import Tool.

8005.8k](/packages/firefly-iii-data-importer)

PHPackages © 2026

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