You can customize certain behaviors of Flight by setting configuration values through the set method.
set
Flight::set('flight.log_errors', true);
The following is a list of all the available configuration settings:
?string
bool
string
Content-Length
There is additionally another configuration setting for the loader. This will allow you to autoload classes with _ in the class name.
_
// Enable class loading with underscores // Defaulted to true Loader::$v2ClassLoading = false;
Flight allows you to save variables so that they can be used anywhere in your application.
// Save your variable Flight::set('id', 123); // Elsewhere in your application $id = Flight::get('id');
To see if a variable has been set you can do:
if (Flight::has('id')) { // Do something }
You can clear a variable by doing:
// Clears the id variable Flight::clear('id'); // Clears all variables Flight::clear();
Flight also uses variables for configuration purposes.
All errors and exceptions are caught by Flight and passed to the error method. The default behavior is to send a generic HTTP 500 Internal Server Error response with some error information.
error
HTTP 500 Internal Server Error
You can override this behavior for your own needs:
Flight::map('error', function (Throwable $error) { // Handle error echo $error->getTraceAsString(); });
By default errors are not logged to the web server. You can enable this by changing the config:
When a URL can't be found, Flight calls the notFound method. The default behavior is to send an HTTP 404 Not Found response with a simple message.
notFound
HTTP 404 Not Found
Flight::map('notFound', function () { // Handle not found });