Runway is a CLI application that helps you manage your Flight applications. It can generate controllers, display all routes, and more. It is based on the excellent adhocore/php-cli library.
Install with composer.
composer require flightphp/runway
The first time you run Runway, it will run you through a setup process and create a .runway.json configuration file in the root of your project. This file will contain some necessary configurations for Runway to work properly.
.runway.json
Runway has a number of commands that you can use to manage your Flight application. There are two easy ways to use Runway.
php runway [command]
vendor/bin/runway [command]
For any command, you can pass in the --help flag to get more information on how to use the command.
--help
php runway routes --help
Here are a few examples:
Based on the configuration in your .runway.json file, the default location will generate a controller for you in the app/controllers/ directory.
app/controllers/
php runway make:controller MyController
This will display all of the routes that are currently registered with Flight.
php runway routes
If you would like to only view specific routes, you can pass in a flag to filter the routes.
# Display only GET routes php runway routes --get # Display only POST routes php runway routes --post # etc.
If you are either creating a package for Flight, or want to add your own custom commands into your project, you can do so by creating a src/commands/, flight/commands/, app/commands/, or commands/ directory for your project/package.
src/commands/
flight/commands/
app/commands/
commands/
To create a command, you simple extend the AbstractBaseCommand class, and implement at a minimum a __construct method and an execute method.
AbstractBaseCommand
__construct
execute
<?php declare(strict_types=1); namespace flight\commands; class ExampleCommand extends AbstractBaseCommand { /** * Construct * * @param array<string,mixed> $config JSON config from .runway-config.json */ public function __construct(array $config) { parent::__construct('make:example', 'Create an example for the documentation', $config); $this->argument('<funny-gif>', 'The name of the funny gif'); } /** * Executes the function * * @return void */ public function execute(string $controller) { $io = $this->app()->io(); $io->info('Creating example...'); // Do something here $io->ok('Example created!'); } }
See the adhocore/php-cli Documentation for more information on how to build your own custom commands into your Flight application!