lsv / airlabs
Requires
- php: >=8.2
- nyholm/psr7: ^1.5
- php-http/httplug: ^2.3
- php-http/message-factory: ^1.0
- phpdocumentor/reflection-docblock: ^5.3
- psr/http-factory: ^1.0
- psr/http-message: ^1.0
- symfony/event-dispatcher: ^6.2
- symfony/http-client: ^6.2
- symfony/http-foundation: ^6.2
- symfony/options-resolver: ^6.2
- symfony/property-access: ^6.2
- symfony/property-info: ^6.2
- symfony/psr-http-message-bridge: ^2.1
- symfony/serializer: ^6.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.13
- infection/infection: ^0.26.18
- phpstan/extension-installer: ^1.2
- phpstan/phpstan: ^1.9
- phpunit/phpunit: ^9.5
- psalm/plugin-phpunit: ^0.18.4
- rregeer/phpunit-coverage-check: ^0.3.1
- vimeo/psalm: ^5.6
This package is auto-updated.
Last update: 2024-10-29 06:31:14 UTC
README
PHP Wrapper for Airlabs APIs
Install
composer require lsv/airlabs
Usage
Quick example
To get flight information
require 'vendor/autoload.php'; $apikey = '<your api key>'; $factory = new \Lsv\Airlabs\RequestFactory($apikey); $request = new \Lsv\Airlabs\Request\FlightInformationRequest( flightCode: new \Lsv\Airlabs\Utils\IcaoIataCode(null, 'AA6') ); $response = $factory->call($request); echo $response->depTime; // Would write departure time for this aircraft
Factory
require 'vendor/autoload.php'; $apikey = '<your api key>'; $factory = new \Lsv\Airlabs\RequestFactory($apikey); $request = instance of \Lsv\Airlabs\RequestInterface::class; // See below for requests available $response = $factory->call($request);
Requests
Airline Fleet
$request = new \Lsv\Airlabs\Request\AirlineFleetRequest() $optionalParameters = [ 'airlineCode' => new \Lsv\Airlabs\Utils\IcaoIataCode('icao', 'iata'), // only add either icao or iata code 'hex' => 'H12345', // ICAO24 Hex address 'reg_number' => 'OY-123', // Aircraft registration number 'msn' => '', // Manufacturer Serial Number 'flag' => 'DK' // Country code ]; $request = new \Lsv\Airlabs\Request\AirlineFleetRequest(...$optionalParameters); // Response array of \Lsv\Airlabs\Response\AirlineFleetResponse() // If using a free account array of \Lsv\Airlabs\Response\AirlineFleetFreeResponse()
Airline
$request = new \Lsv\Airlabs\Request\AirlineRequest() $optionalParameters = [ 'airlineCode' => new \Lsv\Airlabs\Utils\IcaoIataCode('icao', 'iata'), // only add either icao or iata code 'iataPrefix' => '1', // IATA prefix number 'iataAccounting' => '1', // IATA accounting number 'callsign' => 'AMERICAN', // ICAO callsign 'name' => 'American Airlines', // Airline name 'countryCode' => 'DK' // Country code ]; $request = new \Lsv\Airlabs\Request\AirlineFleetRequest(...$optionalParameters); // Response array of \Lsv\Airlabs\Response\AirlineResponse() // If using a free account array of \Lsv\Airlabs\Response\AirlineFreeResponse()
Airline Route
$requiredParameters = [ 'departureAirport' => new \Lsv\Airlabs\Utils\IcaoIataCode('icao', 'iata'), // only add either icao or iata code 'arrivalAirport' => new \Lsv\Airlabs\Utils\IcaoIataCode('icao', 'iata'), // only add either icao or iata code 'airlineCode' => new \Lsv\Airlabs\Utils\IcaoIataCode('icao', 'iata'), // only add either icao or iata code ]; $request = new \Lsv\Airlabs\Request\AirlineRouteRequest(...$requiredParameters); $optionalParameters = [ 'flightCode' => new \Lsv\Airlabs\Utils\IcaoIataCode('icao', 'iata'), // only add either icao or iata code 'flightNumber' => '1', // Flight number ]; $request = new \Lsv\Airlabs\Request\AirlineRouteRequest(...array_merge($requiredParameters, $optionalParameters)); array of \Lsv\Airlabs\Response\AirlineRouteResponse() // If using a free account array of \Lsv\Airlabs\Response\AirlineFreeResponse()
Flight Information
$requiredParameters = [ 'flightCode' => new \Lsv\Airlabs\Utils\IcaoIataCode('icao', 'iata'), // only add either icao or iata code ]; $request = new \Lsv\Airlabs\Request\FlightInformationRequest(...$requiredParameters); instance of new \Lsv\Airlabs\Response\FlightInformationResponse()
Flight Schedule
$requiredParameters = [ 'departureAirport' => new \Lsv\Airlabs\Utils\IcaoIataCode('icao', 'iata'), // only add either icao or iata code 'arrivalAirport' => new \Lsv\Airlabs\Utils\IcaoIataCode('icao', 'iata'), // only add either icao or iata code 'airlineCode' => new \Lsv\Airlabs\Utils\IcaoIataCode('icao', 'iata'), // only add either icao or iata code ]; $request = new \Lsv\Airlabs\Request\FlightScheduleRequest(...$requiredParameters); $optionalParameters = [ 'flightCode' => new \Lsv\Airlabs\Utils\IcaoIataCode('icao', 'iata'), // only add either icao or iata code 'flightNumber' => '1', // Flight number ]; $request = new \Lsv\Airlabs\Request\FlightScheduleRequest(...array_merge($requiredParameters, $optionalParameters)); array of \Lsv\Airlabs\Response\FlightScheduleResponse()
Flight Tracker
$request = new \Lsv\Airlabs\Request\FlightTrackerRequest(); $optionalParameters = [ 'box' => new \Lsv\Airlabs\Utils\BoundaryBox($swLat, $swLng, $neLat, $neLng), // Boundary box from where you want data from 'hex' => '1', // ICAO24 Hex address 'registrationNumber' => '1', // Aircraft Registration number. 'airlineCode' => new \Lsv\Airlabs\Utils\IcaoIataCode('icao', 'iata'), // Airline code 'flag' => 'DK', // Country code 'flightCode' => new \Lsv\Airlabs\Utils\IcaoIataCode('icao', 'iata'), // Flight code 'flightNumber' => '1', // Flight number 'departureAirport' => new \Lsv\Airlabs\Utils\IcaoIataCode('icao', 'iata'), // Departure airport 'arrivalAirport' => new \Lsv\Airlabs\Utils\IcaoIataCode('icao', 'iata'), // Arrival airport ]; $request = new \Lsv\Airlabs\Request\FlightTrackerRequest(...$optionalParameters); array of \Lsv\Airlabs\Response\FlightTrackerResponse()
License
MIT License
Copyright (c) 2023 Martin Aarhof
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.