PHP code example of tomoehlrich / taxifarefinder

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

    

tomoehlrich / taxifarefinder example snippets


// config/app.php
'providers' => [
    // ...
    TomOehlrich\TaxiFareFinder\TaxiFareFinderServiceProvider::class
];

// config/app.php
'aliases' => [
	// ...
	'TaxiFareFinder' => TomOehlrich\TaxiFareFinder\Facades\TaxiFareFinder::class,
]

return [

    /*
    |--------------------------------------------------------------------------
    | TaxiFareFinder API Key
    |--------------------------------------------------------------------------
    |
    | The TaxiFareFinder API Key can be requested at
    | https://www.taxifarefinder.com/contactus.php
    |
    */

    'api_key' => env('TAXIFAREFINDER_API_KEY', ''),

];

$tff = new TaxiFareFinder('<YOUR API KEY>');


return $tff->getNearestCity(1.290270, 103.851959);

/*
  This function returns the following array:

  Array
    (
        [name] => Singapore
        [full_name] => Singapore, Singapore
        [handle] => Singapore
        [locale] => zh_SG
        [distance] => 7747
    )


return $tff->getTaxiFare(42.368025,-71.022155, 42.362571,-71.055543);

/*
  This function returns the following array:

  Array
    (
        [total_fare] => 20.61
        [initial_fare] => 2.6
        [metered_fare] => 10.42
        [tip_amount] => 2.69
        [tip_percentage] => 15
        [locale] => en_US
        [currency] => Array
            (
                [int_symbol] => USD
            )

        [rate_area] => Boston, MA
        [flat_rates] => Array
            (
            )

        [extra_charges] => Array
            (
                [0] => Array
                    (
                        [charge] => 2.25
                        [description] => Airport Fee
                    )

                [1] => Array
                    (
                        [charge] => 2.65
                        [description] => Harbor tunnel toll
                    )

            )

        [distance] => 4591.1
        [duration] => 544
    )


return $tff->getTaxiCompanies('Ho-Chi-Minh-Vietnam');

/*
  This function returns the following array:

  Array
    (
        [businesses] => Array
            (
                [0] => Array
                    (
                        [name] => DichungTaxi
                        [phone] => 093-607-0416
                        [type] => taxi
                    )

            )

    )


return TaxiFareFinder::getNearestCity(1.290270, 103.851959);


try {
    $fare = $tff->getTaxiFare(42.368025,-71.022155, 42.362571,-71.055543);
} catch(TomOehlrich\TaxiFareFinder\Exceptions\TffException $e) {
    return $e->getMessage();
} catch(\Exception $e) {
    return $e->getMessage();
}

bash
php artisan vendor:publish --provider="TomOehlrich\TaxiFareFinder\TaxiFareFinderServiceProvider"