steefdw / airports
Airports
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:package
Requires
- php: ^8.2
- nesbot/carbon: ^3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.11
- phpmd/phpmd: ^2.13
- phpstan/phpstan: ^1.8.8
- phpunit/phpunit: ^9.5.25
- rector/rector: ^1.0
- squizlabs/php_codesniffer: ^3.7.1
This package is not auto-updated.
Last update: 2025-04-18 16:52:49 UTC
README
Inspired by CGP Grey's video: ✈️ The Maddening Mess of Airport Codes! ✈️
Installation
composer require steefdw/airports
Usage
Get an airport by its IATA code:
$amsterdam = Airports::getAirport('AMS'); // Steefdw\Airports\Airport^ { // +icao: "EHAM" // +iata: "AMS" // +name: "Amsterdam Airport Schiphol" // +city: "Amsterdam" // +state: "North-Holland" // +country: "NL" // +elevation: -11 // +lat: 52.3086013794 // +lon: 4.7638897896 // +timezone: "Europe/Amsterdam" // }
Get the distance between two airports:
$amsterdam = Airports::getAirport('AMS'); $barcelona = Airports::getAirport('BCN'); $distance = $amsterdam->getDistance($barcelona); // 1241.0765638345 (km)
Get the time difference between two airports:
$amsterdam = Airports::getAirport('AMS'); $london = Airports::getAirport('LTN'); $timeDiff = $amsterdam->getTimeDiff($london); // -1 (hour)
Get an array of airports:
Airports::getAirports(); // get all ~29k airports in the world Airports::getIataAirports(); // only the 7780 airports that have a three-letter IATA code. Airports::getAirportsByCountryCode('nl'); // only get the 27 airports in the Netherlands