anglemx/airports
Composer 安装命令:
composer require anglemx/airports
包简介
Auto-generated PHP abstract class that contains the global IATA Aiport database in pure PHP code.
README 文档
README
This library is an auto-generated PHP abstract class that contains the global IATA Aiport database in pure PHP code.
The database is pulled from the ICAO Airport database published by mwgg at github.com/mwgg/Airports.
Last update: 2024-02-09
Note: we haven't tested if this is faster than loading from a raw .json file or a SQLite database. However, it definitely simplifies our deployment processes. Please feel free to run benchmarks and submit pull requests!
Installation
composer require anglemx/airports
Usage
After installing it with Composer, simply import it into your code.
use Angle\Airports\AirportLibrary;
Find a single airport from a known IATA code
/** @var \Angle\Airports\Airport $airport */ $airport = AirportLibrary::find('LMM');
An airport entry contains:
var_dump($airport);
/**
object(Angle\Airports\Airport)(10) {
["icao"]=>
string(4) "MMLM"
["iata"]=>
string(3) "LMM"
["name"]=>
string(38) "Valle del Fuerte International Airport"
["city"]=>
string(10) "Los Mochis"
["state"]=>
string(7) "Sinaloa"
["country"]=>
string(2) "MX"
["elevation"]=>
int(16)
["lat"]=>
float(25.6851997375)
["lon"]=>
float(-109.081001282)
["tz"]=>
string(16) "America/Mazatlan"
}
*/
// If needed, the `Airport` object can also be casted as an array:
var_dump($airport->toArray());
/**
array(10) {
["iata"]=>
string(3) "LMM"
["icao"]=>
string(4) "MMLM"
["name"]=>
string(38) "Valle del Fuerte International Airport"
["city"]=>
string(10) "Los Mochis"
["state"]=>
string(7) "Sinaloa"
["country"]=>
string(2) "MX"
["elevation"]=>
int(16)
["lat"]=>
float(25.6851997375)
["lon"]=>
float(-109.081001282)
["tz"]=>
string(16) "America/Mazatlan"
}
*/
Find all the airports in a country
/** @var \Angle\Airports\Airport[] $airports */ $airports = AirportLibrary::findByCountry('MX');
Returns an array of airports for the specified country, with the IATA code as the key of each entry.
Get the full airport list
$airports = AirportLibrary::getFullList();
Returns an array of all the airports (as arrays, not objects) in the list, with the IATA code as the key of each entry.
Build / Update
Requirements:
- ext-curl
- ext-json
Run the script at:
$> php build/build.php
This will download the newest copy of the source airports.json from the GitHub repository into a temporary file, it will parse it and it will replace the placeholder found in build/AirportLibrary.php to write the final auto-generated file to src/AirportLibrary.php.
Do not modify the file in src/AirportLibrary.php directly. Instead modify the template file in the build/ directory, and then run the build.php script.
We're targeting PHP 5.3 even thought it's quite old at this point, in order to maintain compatibility with older codebases. This means:
- Not using PHP7's constant arrays or any other modern features that could speed up the performance of the library.
- Using PHPUnit 4 even thought it's deprecated by now.
Testing
The library is very simple, but we wrote some "tests" just for the heck of it. These require PHPUnit 4.
$> composer install
$> ./vendor/bin/phpunit tests/AirportLibraryTest
Credits
The source information is pulled from the ICAO Airport database published by mwgg at github.com/mwgg/Airports.
License
MIT License. © 2019 Angle Consulting.
anglemx/airports 适用场景与选型建议
anglemx/airports 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13.06k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2019 年 07 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「angle」 「airports」 「iata」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 anglemx/airports 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 anglemx/airports 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 anglemx/airports 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Common PHP utilities, functions & scripts used by Angle
IATA SSIM schedules parser
Laravel Airports is a bundle for Laravel, providing Iata Code ISO 3166 3 and country codes for all the airports.
Common Symfony Framework (PHP) utilities, functions & scripts used by Angle
A PHP support for string, decimal, radian and object angles, providing goniometric algebra and comparison between angles.
Parse and validate CFDIs against SAT México
统计信息
- 总下载量: 13.06k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-07-27