tomoehlrich/taxifarefinder
Composer 安装命令:
composer require tomoehlrich/taxifarefinder
包简介
A PHP/Laravel wrapper for the TaxiFareFinder API
README 文档
README
This package can retrieve supported cities, taxi businesses and taxi fare information from the TaxiFareFinder API.
The TaxiFareFinder API key can be requested under https://www.taxifarefinder.com/contactus.php.
Installation
This package can be installed through composer.
composer require tomoehlrich/taxifarefinder
Laravel installation
This package can be used for Laravel and non-Laravel projects.
In Laravel 5.5+ the package will make use of the Laravel autoregister feature. In older versions of Laravel you have to manually install the package's service provider and facade.
// config/app.php 'providers' => [ // ... TomOehlrich\TaxiFareFinder\TaxiFareFinderServiceProvider::class ];
// config/app.php 'aliases' => [ // ... 'TaxiFareFinder' => TomOehlrich\TaxiFareFinder\Facades\TaxiFareFinder::class, ]
Next, you have to publish the config file:
php artisan vendor:publish --provider="TomOehlrich\TaxiFareFinder\TaxiFareFinderServiceProvider"
The config file contains only one option. Please make sure that your API key is available here.
return [ /* |-------------------------------------------------------------------------- | TaxiFareFinder API Key |-------------------------------------------------------------------------- | | The TaxiFareFinder API Key can be requested at | https://www.taxifarefinder.com/contactus.php | */ 'api_key' => env('TAXIFAREFINDER_API_KEY', ''), ];
Usage
First create a new instance of the TaxiFareFinder class.
$tff = new TaxiFareFinder('<YOUR API KEY>');
You can get the nearest city that is supported by the API:
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 )
You can get details about a taxi fare.
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 )
You can get a list of taxi companies in a city.
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 ) ) )
In Laravel you can just call
return TaxiFareFinder::getNearestCity(1.290270, 103.851959);
To catch exceptions you should wrap methods in a try .. catch block.
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(); }
This package comes with a couple of tests. Just enter your API key in tests/TestCase.php and run
composer test
tomoehlrich/taxifarefinder 适用场景与选型建议
tomoehlrich/taxifarefinder 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 02 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「laravel」 「taxifarefinder」 「taxi fare」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tomoehlrich/taxifarefinder 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tomoehlrich/taxifarefinder 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tomoehlrich/taxifarefinder 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Alfabank REST API integration
Zero-dependency raw PHP DNS resolver, domain-ownership verification, and intoDNS/MxToolbox-style diagnostics. Queries authoritative nameservers directly over sockets — never trusts the recursive cache for ownership checks.
Laravel package for Accurate Online API integration.
A lightweight plain-PHP framework for database-backed CRUD APIs.
bughq error tracking - PHP SDK
Shared RCX Laravel DataTables UI and configuration helpers.
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-10