PHP code example of flairuk / laravel-aviationstack

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

    

flairuk / laravel-aviationstack example snippets


use FLAIRUK\Aviationstack\Facades\Aviationstack;

Aviationstack::flights()->from('LHR')->to('JFK')->status('active')->get();
Aviationstack::flights()->flight('BA117')->on('2026-09-30')->first();
Aviationstack::timetable('JFK')->arrivals()->status('landed')->get();
Aviationstack::futureFlights('BER', '2026-12-01')->airline('AF')->get();
Aviationstack::airports()->search('heathrow')->first();
Aviationstack::airlines()->lazy()->each(fn (array $airline) => /* … */);

$page = Aviationstack::flights()->from('LHR')->page(2, perPage: 50)->get();

$page->data;       // array of rows, exactly as the API returned them
$page->total;      // size of the whole result set
$page->offset;     // where this page starts
$page->hasMore();
$page->first();
$page->collect();  // Illuminate\Support\Collection
count($page); foreach ($page as $row) { … }

Aviationstack::airports()->lazy(maxPages: 5)->take(300)->all();
dotenv
AVIATIONSTACK_KEY=…
AVIATIONSTACK_HTTPS=true      # false on the free plan, which refuses HTTPS (error 105)
AVIATIONSTACK_MAX_LIMIT=100   # 1000 on Professional and above
bash
php artisan vendor:publish --tag=aviationstack-config