PHP code example of unifyunits / unifyunits-laravel

1. Go to this page and download the library: Download unifyunits/unifyunits-laravel 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/ */

    

unifyunits / unifyunits-laravel example snippets


use UnifyUnits\Laravel\Contracts\UnifyUnitsClient;

class QuoteController
{
    public function __invoke(UnifyUnitsClient $units)
    {
        $conversion = $units->convert('1000', 'm', 'km');

        return $conversion['data']['result']; // ['value' => '1', 'unit' => 'km']
    }
}

use UnifyUnits\Laravel\Facades\UnifyUnits;

$result = UnifyUnits::convert('72', 'mi/h', 'km/h');
sh
php artisan vendor:publish --tag=unifyunits-config