Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
phpvms
https://docs.phpvms.net
Admin
Tokens:
36,866
Snippets:
304
Trust Score:
9.4
Update:
6 months ago
Context
Chat
Benchmark
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Install Dependencies with npm Source: https://docs.phpvms.net/acars/plugins/getting-started Installs the necessary project dependencies using npm. This is a prerequisite for running other build and development commands. ```bash npm install ``` -------------------------------- ### Callback Script setup() Method Example (ACARS Script) Source: https://docs.phpvms.net/acars/plugins/callbacks Demonstrates the setup() method within an ACARS callback script. This method is executed once upon script initialization and is used for setting initial states or variables using Acars.Set(). ```acars_script setup() { Acars.Set('above_1k', false) Acars.Set('launched_message', false) } ``` -------------------------------- ### Composer Install for phpVMS Dependencies Source: https://docs.phpvms.net/installation This command-line snippet navigates to the phpVMS project directory and installs the necessary Composer dependencies. This step is required only if you have cloned the repository or downloaded the raw source files, not for release versions. ```bash cd /path/to/phpvms composer install ``` -------------------------------- ### Build Project Files with npm Source: https://docs.phpvms.net/acars/plugins/getting-started Compiles Typescript to Javascript and creates a 'dist' directory containing the build output. This command does not copy files or create a distribution package. ```bash npm run build ``` -------------------------------- ### Example Callback Script Implementation (TypeScript) Source: https://docs.phpvms.net/acars/plugins/callbacks A comprehensive example of a callback script implementing the CallbackHook interface. It demonstrates the setup, run, and phaseChange methods, showcasing interactions with the ACARS system for setting fields, logging, and playing audio. This script is intended as a learning tool. ```typescript import {PirepState} from '../defs'; import {CallbackHook, Meta} from '../types/callback'; import {Pirep, Telemetry} from '../types/types'; /** * This is an example script. It's not very useful, but it's a good example of * how to write a script and some of the functionality. */ export default class ExampleScript implements CallbackHook { meta: Meta = { id: 'example_script', name: 'Example Script', enabled: false, }; setup() { Acars.Set('above_1k', false); Acars.Set('launched_message', false); } /** * This once a second. * @param pirep * @param data */ run(pirep: Pirep, data: Telemetry): void { Acars.SetPirepField('Loaded', 'True'); Acars.AddPirepLogOnce('loaded_msg', 'Example script loaded'); // Example of setting a flag to check later on if (data.groundAltitude.Feet > 1000) { Acars.Set('above_1k', true); Acars.SetPirepField('Above 1000 feet', 'True'); } /* * Just a silly example, if they crossed above 1000 feet and then they went * back below it, send a message about that */ if (Acars.Get('above_1k') === true && data.groundAltitude.Feet < 1000) { Acars.AddPirepLog("Went above 1000', now back down"); } } /** * Called on phase changes */ phaseChange( pirep: Pirep, data: Telemetry, newPhase: PirepState, oldPhase: PirepState, ) { Acars.AddPirepLog(`Phase changed from ${oldPhase} to ${newPhase}`); if (newPhase == PirepState.Pushback) { Acars.PlayAudio('departure.mp3'); } } } ``` -------------------------------- ### MySQL Database Setup and User Creation Source: https://docs.phpvms.net/installation This SQL script creates a new MySQL database named 'phpvms', sets its character set and collation to UTF8, creates a user 'phpvms' with the specified password, grants all privileges on the database to this user, and flushes privileges. Ensure you replace 'password' with a strong, unique password. ```sql CREATE DATABASE IF NOT EXISTS `phpvms` CHARACTER SET UTF8 COLLATE utf8_unicode_ci; CREATE USER 'phpvms'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON phpvms.* TO 'phpvms'@'localhost'; FLUSH PRIVILEGES; ``` -------------------------------- ### Install TAP Testing Framework Source: https://docs.phpvms.net/acars/plugins/rules This command installs the TAP (Test Anything Protocol) testing framework as a development dependency for your project. TAP is used to run your tests and report results. ```bash npm install --save-dev tap ``` -------------------------------- ### Create Distribution Package with npm Source: https://docs.phpvms.net/acars/plugins/getting-started Builds the project and creates a distributable zip file (e.g., dist.zip). This package can be uploaded and used by ACARS. The contents of the zip can be customized in the gulpfile.mjs. ```bash npm run dist ``` -------------------------------- ### Development Mode with npm Source: https://docs.phpvms.net/acars/plugins/getting-started Starts a watch process that automatically transpiles Typescript to Javascript and copies the build output to the ACARS profile path defined in the .env file. This is useful for rapid development and testing. ```bash npm run dev ``` -------------------------------- ### Clone and Install phpVMS with Docker Source: https://docs.phpvms.net/developers/environment This snippet clones the phpVMS repository and installs dependencies using Docker and Composer. It then starts the Laravel Sail environment and runs the development installation command to set up the database and configuration. ```bash git clone https://github.com/nabeelio/phpvms.git phpvms cd phpvms docker run --rm \ -u "$(id -u):$(id -g)" \ -v "$(pwd):/var/www/html" \ -w /var/www/html \ laravelsail/php83-composer:latest \ composer install --ignore-platform-reqs ./vendor/bin/sail up -d ./vendor/bin/sail artisan phpvms:dev-install ``` -------------------------------- ### Run phpVMS Importer via Command Line Source: https://docs.phpvms.net/installation/legacy-upgrade This command-line instruction allows you to import data from a legacy phpVMS 5.x installation into a new phpVMS installation. Ensure you have installed phpVMS and that the config.php and .env files exist. This process will erase current data. ```bash cd /path/to/phpvms php artisan phpvms:importer {db_host} {db_name} {db_user} {db_pass?} ``` ```bash php artisan phpvms:importer "localhost" "phpvms_legacy" "php_legacy_username" "phpvms_legacy_password" ``` -------------------------------- ### Clone phpVMS Repository and Install Dependencies (Bash) Source: https://docs.phpvms.net/download This snippet demonstrates how to clone the phpVMS repository from GitHub and install its dependencies using Composer. It's a common method for developers who want the latest code or to contribute to the project. Ensure you have Git and Composer installed before running these commands. ```bash git clone https://github.com/nabeelio/phpvms.git cd phpvms composer install ``` -------------------------------- ### Create Migration and Seed Data Source: https://docs.phpvms.net/developers/addons A migration class example showing how to define a table schema and insert initial seed data using the SeederService. ```php <?php use App\Contracts\Migration; use App\Services\Installer\SeederService; use Illuminate\Database\Schema\Blueprint; class CreateSettingsTable extends Migration { public function up() { Schema::create('myaddon_settings', function (Blueprint $table) { // ... Create all the columns }); $settings = [ [ 'order' => 1, 'name' => 'Start Date', 'group' => 'general', 'value' => '', 'type' => 'date', 'description' => 'The date your VA started', ], ]; $this->addData('myaddon_settings', $settings); } } ``` -------------------------------- ### Accessing Module Configuration Value Source: https://docs.phpvms.net/developers/addons This example demonstrates how to retrieve a configuration value from a module's configuration file. The configuration keys are typically prefixed with the module's name. ```php echo config('sample.name'); # writes out "Sample" ``` -------------------------------- ### Install phpVMS Without Docker Source: https://docs.phpvms.net/developers/environment This command sequence clones the phpVMS repository and installs dependencies using Composer. It then runs the development installation command to set up the database and configuration, suitable for environments like Laravel Herd or Laragon. ```bash git clone https://github.com/nabeelio/phpvms.git phpvms cd phpvms composer install php artisan phpvms:dev-install ``` -------------------------------- ### Handle Mixed Priorities for Aircraft Configurations (TypeScript) Source: https://docs.phpvms.net/acars/plugins/aircraftconfigs Illustrates how to manage mixed priorities when multiple scripts match a particular aircraft. It shows two example classes, `Example` and `ExampleOverride`, each with a `meta` object defining its `priority`. The `features` object specifies different lookups for `BeaconLights` and `LandingLights`, with the higher priority script's lookups taking precedence for omitted features. ```typescript import {FeatureAddresses} from './aircraft'; export default class Example extends AircraftConfig { meta: Meta = { // ... priority: 1, }; features: FeatureAddresses = { [AircraftFeature.BeaconLights]: { 'sample/dataref/1': FeatureType.Bool, 'sample/dataref/2': FeatureType.Bool, }, [AircraftFeature.LandingLights]: { 'sample/landing/light/1': FeatureType.Bool, 'sample/landing/light/2': FeatureType.Bool, }, }; } export default class ExampleOverride { meta: Meta = { // ... priority: 10, }; features: FeatureAddresses = { [AircraftFeature.LandingLights]: { 'override/landing/light/1': FeatureType.Bool, 'override/landing/light/2': FeatureType.Bool, }, }; } ``` -------------------------------- ### Sample Module Controller Implementation Source: https://docs.phpvms.net/developers/addons This is a basic example of a controller within a phpVMS module. It extends the base Controller and includes a method to display a view, typically located within the module's resources. ```php <?php namespace Modules\Sample\Http\Controllers; use App\Http\Controllers\Controller; use Illuminate\Http\Request; class SampleController extends Controller { // ... /** * Display a listing of the resource. */ public function index() { return view('sample::index'); } // ... } ``` -------------------------------- ### Setup package.json for VA Rules Testing Source: https://docs.phpvms.net/acars/plugins/rules This JSON configuration file sets up the necessary scripts and metadata for testing VA rules using the TAP testing framework. It defines the package name, version, author, module type, and a script to run tests. ```json { "name": "VA Rules", "version": "1.0.0", "author": "Your Name", "type": "module", "scripts": { "tests": "tap" } } ``` -------------------------------- ### Include Theme Assets in Public Folder (PHP) Source: https://docs.phpvms.net/customize/theming Demonstrates how to correctly reference theme assets within the public folder using the `public_asset()` helper function. This ensures assets are accessible regardless of the server setup. ```php echo public_asset('assets/my-theme/img/someimage.png'); ``` -------------------------------- ### Define Eloquent Model Relationships Source: https://docs.phpvms.net/developers/addons Example of creating a belongsTo relationship within a custom model to link data records. ```php namespace Modules\Sample\Models; use App\Contracts\Model; class SampleTable extends Model { public function pirep() { return $this->belongsTo(Pirep::class, 'pirep_id'); } } ``` -------------------------------- ### Implement CallbackHook Interface for Custom Scripts Source: https://docs.phpvms.net/acars/plugins/callbacks This snippet demonstrates how to implement the CallbackHook interface by defining the required meta property and the three lifecycle methods: setup, run, and phaseChange. It serves as the foundation for creating custom telemetry processing scripts within the application. ```typescript export default class MyScript implements CallbackHook { meta: Meta = { id: 'my_unique_script_id', name: 'My Script Name', enabled: true, }; setup() { // Initialize your script } run(pirep: Pirep, data: Telemetry, previousData?: Telemetry) { // Regular processing } phaseChange( pirep: Pirep, data: Telemetry, newPhase: PirepState, oldPhase: PirepState, ) { // Handle phase transitions } } ``` -------------------------------- ### Create New Theme from Scratch (JSON Manifest) Source: https://docs.phpvms.net/customize/theming Defines the manifest file for a new theme. The 'name' is required, 'asset-path' specifies where theme assets are located relative to the public path, and 'extends' allows inheriting from a parent theme. Additional custom settings can be included. ```json { "name": "THEME_NAME", "asset-path": "ASSET_PATH", "extends": "PARENT_THEME" } ``` -------------------------------- ### Disable Automatic Configuration Downloads Source: https://docs.phpvms.net/acars/plugins/getting-started Disables the automatic downloading of the latest default configurations for ACARS. This allows for manual editing of local scripts and configurations. The log level can also be adjusted. ```json { "Config": { "App": { "DownloadConfig": false } }, "Serilog": { "MinimumLevel": { "Default": "Verbose" } } } ``` -------------------------------- ### Write a TAP Test for Lights Function Source: https://docs.phpvms.net/acars/plugins/rules This JavaScript code demonstrates how to write a test case for the 'lights' function using the TAP testing framework. It imports necessary modules, sets up mocks, and asserts the expected output of the rule's evaluation. ```javascript import t from 'tap'; import * as Lights from '../lights.js'; import {createMocks} from './mocks.js'; t.before(createMocks); t.test('Test the lights function', (t) => { const rule = new Lights.Rule(); // You can pass the data that is only relevent to your rule here in the PIREP and Data objects t.equal(rule.evaluate({}, {}), 0); t.end(); }); ``` -------------------------------- ### GET /api/pireps/{PIREP ID}/acars/positions Source: https://docs.phpvms.net/api/apis Get the ACARS data in plain rows for a specific PIREP. This endpoint provides raw ACARS position data. ```APIDOC ## GET /api/pireps/{PIREP ID}/acars/positions ### Description Get the ACARS data in plain rows for a specific PIREP. This endpoint provides raw ACARS position data. ### Method GET ### Endpoint /api/pireps/{PIREP ID}/acars/positions ### Parameters #### Path Parameters - **PIREP ID** (string) - Required - The unique identifier of the PIREP. ### Response #### Success Response (200) - The response format for this endpoint is not explicitly defined in the provided text, but it is expected to return ACARS position data. #### Response Example (Example response not provided in the source text) ``` -------------------------------- ### Accessing Eager-Loaded Relationships Source: https://docs.phpvms.net/developers/addons Demonstrates how to query a model with eager-loading and access nested relationship properties. ```php $record = SampleTable::with(['pirep'])->get(1); echo $record->pirep->dpt_airport_id; echo $record->pirep->dpt_airport->name; ``` -------------------------------- ### GET /api/flights Source: https://docs.phpvms.net/api/apis Retrieves a paginated list of all available flights in the system. ```APIDOC ## GET /api/flights ### Description Returns all of the flights in the system, provided in a paginated format. ### Method GET ### Endpoint /api/flights ### Parameters #### Query Parameters - **flight_type** (string) - Optional - Filter flights by specific flight type. ### Response #### Success Response (200) - **data** (array) - List of flight objects - **links** (object) - Pagination navigation links - **meta** (object) - Pagination metadata ### Response Example { "data": [ { "id": "flightid_1", "flight_number": 100, "dpt_airport_id": "KAUS", "arr_airport_id": "KJFK" } ], "meta": { "current_page": 1, "total": 1 } } ``` -------------------------------- ### GET /api/airports Source: https://docs.phpvms.net/api/apis Retrieves a paginated list of all airports available in the system. ```APIDOC ## GET /api/airports ### Description Get all of the airports, paginated list. ### Method GET ### Endpoint /api/airports ### Response #### Success Response (200) - **data** (array) - List of airport objects. - **links** (object) - Pagination links. - **meta** (object) - Pagination metadata. ### Response Example { "data": [ { "id": "KJFK", "iata": "KJFK", "icao": "KJFK", "name": "John F Kennedy International Airport", "city": "New York", "country": "United States", "hub": true } ], "meta": { "current_page": 1, "total": 2 } } ``` -------------------------------- ### Callback Script phaseChange() Method Example (ACARS Script) Source: https://docs.phpvms.net/acars/plugins/callbacks Illustrates the phaseChange() method for ACARS callback scripts. This method is triggered during flight phase transitions and can be used to log changes, play audio, or set PIREP fields based on the new phase. It shows examples for transitioning to TaxiOut and Enroute phases. ```acars_script phaseChange(pirep : Pirep, data : Telemetry, newPhase : PirepState, oldPhase : PirepState ) { Acars.AddPirepLog(`Phase changed from ${oldPhase} to ${newPhase}`) if (newPhase === PirepState.TaxiOut) { Acars.PlayAudio('departure.mp3') } if (newPhase === PirepState.Enroute) { Acars.SetPirepField('Reached Cruise', 'True') } } ``` -------------------------------- ### GET /api/airlines/{ID} Source: https://docs.phpvms.net/api/apis Retrieves detailed information about a specific airline by its ID. ```APIDOC ## GET /api/airlines/{ID} ### Description Get information about a specific airline. ### Method GET ### Endpoint /api/airlines/{ID} ### Parameters #### Path Parameters - **ID** (integer) - Required - The unique identifier of the airline. ### Response #### Success Response (200) - **data** (object) - The airline object containing id, icao, iata, name, country, and logo. ### Response Example { "data": { "id": 1, "icao": "VMS", "iata": "VMS", "name": "phpVMS Airlines", "country": "United States", "logo": null } } ``` -------------------------------- ### Constructor Injection with Repositories in Laravel Source: https://docs.phpvms.net/developers/addons Shows how to use constructor injection to inject a 'PirepRepository' into a listener class. This pattern promotes dependency injection and facilitates testing by decoupling the listener from direct repository instantiation. ```php namespace Modules\Sample\Listeners; use App\Events\PirepAccepted; use App\Repositories\PirepRepository; class PirepAcceptedListener { private $pirepRepo; // You can pass as many Repositories in as your wish. // See the app\Controllers for more examples public function __construct(PirepRepository $pirepRepo) { $this->pirepRepo = $pirepRepo; } public function handle(PirepAccepted $pirep) { Log::info('Received PIREP', [$pirep]); } } ``` -------------------------------- ### GET /api/fleet/aircraft/{id} Source: https://docs.phpvms.net/api/apis Returns information about a specific aircraft, including subfleet details. ```APIDOC ## GET /api/fleet/aircraft/{id} ### Description Return information about an aircraft, including the subfleet information. ### Method GET ### Endpoint /api/fleet/aircraft/{id} ### Parameters #### Path Parameters - **id** (integer) - Required - The database ID of the aircraft. #### Query Parameters - **type** (string) - Optional - Lookup type: registration, tail_number, or icao. ### Response #### Success Response (200) - **data** (object) - Aircraft and subfleet information. ### Response Example { "data": { "id": 1, "registration": "NC17", "subfleet": { "name": "Boeing 747-400" } } } ``` -------------------------------- ### GET /api/flights/{id} Source: https://docs.phpvms.net/api/apis Retrieves detailed information for a specific flight using its unique identifier. ```APIDOC ## GET /api/flights/{id} ### Description Returns detailed information about a specific flight identified by its ID. ### Method GET ### Endpoint /api/flights/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the flight. ### Response #### Success Response (200) - **data** (object) - Detailed flight object including airline, route, and subfleet information. ### Response Example { "data": { "id": "flightid_1", "flight_number": 100, "dpt_airport_id": "KAUS", "arr_airport_id": "KJFK", "flight_type": "J" } } ``` -------------------------------- ### Package Theme for Distribution (Artisan CLI) Source: https://docs.phpvms.net/customize/theming Command to package a created theme into a distributable format. The command generates a theme package file located in the `storage/themes` directory. ```bash php artisan theme:package <theme name> ``` -------------------------------- ### GET /api/airports/{ICAO} Source: https://docs.phpvms.net/api/apis Retrieves detailed information about a specific airport using its ICAO code. ```APIDOC ## GET /api/airports/{ICAO} ### Description Get the details about an airport. ### Method GET ### Endpoint /api/airports/{ICAO} ### Parameters #### Path Parameters - **ICAO** (string) - Required - The ICAO code of the airport. ### Response #### Success Response (200) - **data** (object) - Airport details including location, fuel costs, and timezone. ### Response Example { "data": { "id": "KJFK", "icao": "KJFK", "name": "John F Kennedy International Airport", "hub": true } } ``` -------------------------------- ### Generate Model and Migration via Artisan Source: https://docs.phpvms.net/developers/addons Commands to scaffold new database models and migration files using the phpVMS/Laravel Artisan CLI helper. ```bash php artisan module:make-model SampleTable Sample php artisan module:make-migration create_sample_table ModuleName ``` -------------------------------- ### GET /api/pireps/{PIREP ID} Source: https://docs.phpvms.net/api/apis Retrieves detailed information for a specific PIREP (Pilot Report) using its unique ID. ```APIDOC ## GET /api/pireps/{PIREP ID} ### Description Retrieves the PIREP information for a given PIREP ID. ### Method GET ### Endpoint /api/pireps/{PIREP ID} ### Parameters #### Path Parameters - **PIREP ID** (string) - Required - The unique identifier for the PIREP. #### Query Parameters - **status** (string) - Optional - Filters PIREPs by status. See PIREP Status for possible values. ### Request Example ``` GET /api/pireps/pirepid_1 ``` ### Response #### Success Response (200) Returns the PIREP data including flight details, route, user information, and comments. #### Response Example ```json { "data": { "id": "pirepid_1", "user_id": 1, "airline_id": 1, "aircraft_id": 1, "flight_id": "flightid_1", "flight_number": "100", "route_code": null, "route_leg": null, "dpt_airport_id": "KAUS", "arr_airport_id": "KJFK", "level": null, "distance": null, "planned_distance": null, "flight_time": 180, "planned_flight_time": null, "zfw": null, "block_fuel": null, "fuel_used": null, "landing_rate": null, "route": "KAUS SID TNV J87 IAH J2 LCH J22 MEI J239 ATL J52 AJFEB J14 BYJAC Q60 JAXSN J14 COLIN J61 HUBBS J55 SIE STAR KJFK", "notes": "just a pilot report", "source": 0, "source_name": null, "flight_type": 0, "state": 1, "status": "OFB", "raw_data": null, "created_at": "2018-02-10 23:45:33", "updated_at": "2018-02-10 23:45:33", "airline": { "id": 1, "icao": "VMS", "iata": "VM", "name": "phpvms airlines", "country": null, "logo": null }, "dpt_airport": { "id": "KAUS", "iata": "AUS", "icao": "KAUS", "name": "Austin-Bergstrom", "location": "Austin, Texas, USA", "country": "United States", "timezone": "America/Chicago", "hub": true, "fuel_100ll_cost": 0, "fuel_jeta_cost": 0, "fuel_mogas_cost": 0, "lat": 30.1945278, "lon": -97.6698889 }, "arr_airport": { "id": "KJFK", "iata": "JFK", "icao": "KJFK", "name": "John F Kennedy", "location": "New York, New York, USA", "country": "United States", "timezone": "America/New_York", "hub": true, "fuel_100ll_cost": 0, "fuel_jeta_cost": 0, "fuel_mogas_cost": 0, "lat": 40.6399257, "lon": -73.778695 }, "position": null, "comments": [ { "id": 1, "comment": "A comment", "created_at": { "date": "2018-02-10 23:45:33.000000", "timezone_type": 3, "timezone": "UTC" }, "user": { "id": 1, "pilot_id": "VMS0001", "name": "Admin User" } }, { "id": 2, "comment": "Another comment", "created_at": { "date": "2018-02-10 23:45:33.000000", "timezone_type": 3, "timezone": "UTC" }, "user": { "id": 2, "pilot_id": "VMS0002", "name": "Carla Walters" } } ], "user": { "id": 1, "name": "Admin User", "home_airport_id": "KAUS", "curr_airport_id": "KJFK" }, "fields": [ { "id": 1, "pirep_id": "pirepid_1", "name": "arrival gate", "value": "B14", "source": "manual", "created_at": null, "updated_at": null } ] } } ``` ``` -------------------------------- ### GET /api/flights/search Source: https://docs.phpvms.net/api/apis Allows searching for flights based on various criteria such as departure and arrival airports, airline, and flight number. ```APIDOC ## GET /api/flights/search ### Description Searches for flights based on provided criteria. ### Method GET ### Endpoint /api/flights/search ### Parameters #### Query Parameters - **airline_id** (integer) - Optional - ID of the airline. - **dep_icao** (string) - Optional - Departure airport ICAO code (e.g., KJFK). - **arr_icao** (string) - Optional - Arrival airport ICAO code (e.g., KAUS). - **flight_number** (string) - Optional - Can be a partial match for the flight number. - **route_code** (string) - Optional - The route code for the flight. ### Request Example ``` GET /api/flights/search?depicao=KJFK&arricao=KAUS ``` ### Response #### Success Response (200) Returns a list of flights matching the search criteria. The exact structure is detailed in the `GET /api/flights` endpoint documentation (not provided here). #### Response Example See `GET /api/flights` ```