{"id":48424207,"url":"https://github.com/skoyah/unit-converter","last_synced_at":"2026-04-06T09:09:35.392Z","repository":{"id":33212460,"uuid":"154382621","full_name":"skoyah/unit-converter","owner":"skoyah","description":"A PHP library for converting units of measurement","archived":false,"fork":false,"pushed_at":"2022-03-08T10:13:55.000Z","size":56,"stargazers_count":13,"open_issues_count":1,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-04-03T09:52:06.554Z","etag":null,"topics":["converter","measurements","php","php-library","unit-converter"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skoyah.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-23T19:07:36.000Z","updated_at":"2023-07-11T09:28:07.000Z","dependencies_parsed_at":"2022-08-07T20:15:46.178Z","dependency_job_id":null,"html_url":"https://github.com/skoyah/unit-converter","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/skoyah/unit-converter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skoyah%2Funit-converter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skoyah%2Funit-converter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skoyah%2Funit-converter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skoyah%2Funit-converter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skoyah","download_url":"https://codeload.github.com/skoyah/unit-converter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skoyah%2Funit-converter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31466228,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-06T08:36:52.050Z","status":"ssl_error","status_checked_at":"2026-04-06T08:36:51.267Z","response_time":112,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["converter","measurements","php","php-library","unit-converter"],"created_at":"2026-04-06T09:09:34.752Z","updated_at":"2026-04-06T09:09:35.385Z","avatar_url":"https://github.com/skoyah.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Unit Converter\n\nUnit Converter is a PHP library that makes unit converting a fairly simple an intuitive process.\n\n[![Build Status](https://travis-ci.org/skoyah/unit-converter.svg?branch=master)](https://travis-ci.org/skoyah/unit-converter)\n[![Latest Stable Version](https://poser.pugx.org/skoyah/unit-converter/v/stable)](https://packagist.org/packages/skoyah/unit-converter)\n[![License](https://poser.pugx.org/skoyah/unit-converter/license)](https://packagist.org/packages/skoyah/unit-converter)\n[![StyleCI](https://github.styleci.io/repos/154382621/shield?branch=master)](https://github.styleci.io/repos/154382621)\n___\n## Table of Contents\n\n1. [Installation](#installation)\n2. [Basic Usage](#basic-usage)\n3. [Support](#support)\n4. [Configuration](#configuration)\n5. [Code of Conduct](#code-of-conduct)\n6. [License](#license)\n\n___\n## Installation\n```bash\n$ composer require skoyah/unit-converter\n```\n\n## Basic Usage\n### Namespacing\nThe Unit Converter library is under ```Skoyah\\Converter``` namespace.\n\nOnce you have installed the Unit Converter library, converting from one unit of measurement to another is really simple.\n\nFirst, create a new instance of the desired type and import the related class.\nThe instance needs to accept two parameters -  1) a boolean for the quantity, and 2) a string for the unit of measurement.\n\nNext, all you need is to call a ```to()``` method and pass in the parameter for the convertion.\n\n### Example conversion:\n```php\nuse Skoyah\\Converter\\Mass;\n\n$mass = new Mass(1, 'kg');\necho $mass-\u003eto('pounds'); // '2.20462262'\n```\n\nAlternatively, you can convert using the unit abbreviation as a parameter:\n\n```php\necho $mass-\u003eto('lbs'); // '2.20462262'\n```\n\nThe ```to()``` method has also an optional parameter tor defining how many decimal units should be displayed for the given convertion.\n\n```php\necho $mass-\u003eto('lbs', 2); // '2.20'\n```\n\n## Support\nCurrently, the Unit Converter supports the following types:\n\n* [Mass](#mass-units)\n* [Temperature](#temperature-units)\n* [Length](#length-units)\n* [Pressure](#pressure-units)\n* [Area](#area-units)\n* [Volume](#volume-units) - \u003cem\u003e\u003cstrong\u003eNew\u003c/strong\u003e\u003c/em\u003e\n\n\n## Configuration\nDuring instantiation or convertion, you have two options for defining the unit to be used.\n\nThere is a longform and a short-hand word available for each unit of measure.\n\nFor 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.\n\n### Mass units\n| long       | short   |\n| :--------- | :------ |\n|*tonnes*    |     *t* |\n|*kilograms* |     *kg*|\n|*grams*     |      *g*|\n|*milligrams*|     *mg*|\n|*pounds*    |    *lbs*|\n|*onces*     |     *oz*|\n\n### Temperature units\n| long       | short   |\n| :--------- | :------ |\n|*kelvin*    |      *k*|\n|*celsius*   |      *c*|\n|*fahrenheit*|      *f*|\n\n### Length units\n| long           | short   |\n| :------------- | :------ |\n|*kilometers*    |     *km*|\n|*meters*        |      *m*|\n|*decimeters*    |     *dm*|\n|*centimeters*   |     *cm*|\n|*millimeters*   |     *mm*|\n|*inches*        |     *in*|\n|*feet*          |     *ft*|\n|*yards*         |     *yd*|\n|*miles*         |     *mi*|\n|*nautical miles*|    *nmi*|\n\n### Pressure units\n| long        | short   |\n| :---------- | :------ |\n|*bars*       |    *bar*|\n|*millibars*  |   *mbar*|\n|*kilopascals*|    *kpa*|\n|*pascals*    |     *pa*|\n|*atmospheres*|    *atm*|\n\n### Area units\n| long               | short   |\n| :----------------  | :------ |\n|*square kilometers* |    *km2*|\n|*square meters*     |     *m2*|\n|*square centimeters*|    *cm2*|\n|*square millimeters*|    *mm2*|\n|*square inches*     |    *in2*|\n|*square feet*       |    *ft2*|\n|*square yards*      |    *yd2*|\n\n### Volume units\n| long               | short   |\n| :----------------  | :------ |\n|*cubic millimeters* |    *mm3*|\n|*cubic centimeter*  |    *cm3*|\n|*cubic decimeter*   |    *dm3*|\n|*cubic meter*       |     *m3*|\n|*cubic dekameter*   |   *dam3*|\n|*cubic hectometer*  |    *hm3*|\n|*cubic kilometer*   |    *km3*|\n\n\n\n## Code of Conduct\nIn 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).\n\n## License\nUnit Converter is released under the MIT Licence. Read the [license](https://github.com/skoyah/unit-converter/blob/master/LICENSE.md) file for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskoyah%2Funit-converter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskoyah%2Funit-converter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskoyah%2Funit-converter/lists"}