PHP code example of laravel-enso / unit-conversion

1. Go to this page and download the library: Download laravel-enso/unit-conversion library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

laravel-enso / unit-conversion example snippets


use LaravelEnso\UnitConversion\Length\Length;
use LaravelEnso\UnitConversion\Length\Units\Meter;
use LaravelEnso\UnitConversion\Length\Units\Millimeter;

$result = Length::from(new Meter(2))->to(Millimeter::class);

$result = Length::from('2 m')->to(Millimeter::class);

use LaravelEnso\UnitConversion\Mass\Units\Gram;
use LaravelEnso\UnitConversion\Mass\Units\Kilogram;

$result = Gram::from(new Kilogram(3));

$result = Gram::from('3 kg');