PHP code example of sharpapi / php-utility-airports

1. Go to this page and download the library: Download sharpapi/php-utility-airports 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/ */

    

sharpapi / php-utility-airports example snippets




harpAPI\UtilityAirports\AirportsClient;
use GuzzleHttp\Exception\GuzzleException;

$apiKey = 'your_api_key_here';
$client = new AirportsClient(apiKey: $apiKey);

try {
    // List airports
    $airports = $client->listAirports([
        'country' => 'US',
        'per_page' => 10
    ]);

    // Get specific airport by IATA
    $airport = $client->getAirportByIata('JFK');

    print_r($airport);
} catch (GuzzleException $e) {
    echo "API error: " . $e->getMessage();
}
bash
composer