PHP Class flight\Engine

It is responsible for loading an HTTP request, running the assigned services, and generating an HTTP response.
Afficher le fichier Open project: mikecao/flight Class Usage Examples

Protected Properties

Свойство Type Description
$dispatcher object Event dispatcher.
$loader object Class loader.
$vars array Stored variables.

Méthodes publiques

Méthode Description
__call ( string $name, array $params ) : mixed Handles calls to class methods.
__construct ( ) Constructor.
_error ( object $e ) Sends an HTTP 500 response for any errors.
_etag ( string $id, string $type = 'strong' ) Handles ETag HTTP caching.
_halt ( integer $code = 200, string $message = '' ) Stops processing and returns a given response.
_json ( mixed $data, integer $code = 200, boolean $encode = true, string $charset = 'utf-8', integer $option ) Sends a JSON response.
_jsonp ( mixed $data, string $param = 'jsonp', integer $code = 200, boolean $encode = true, string $charset = 'utf-8', integer $option ) Sends a JSONP response.
_lastModified ( integer $time ) Handles last modified HTTP caching.
_notFound ( ) Sends an HTTP 404 response when a URL is not found.
_redirect ( string $url, integer $code = 303 ) Redirects the current request to another URL.
_render ( string $file, array $data = null, string $key = null ) Renders a template.
_route ( string $pattern, callback $callback, boolean $pass_route = false ) Routes a URL to a callback function.
_start ( ) Starts the framework.
_stop ( integer $code = 200 ) Stops the framework and outputs the current response.
after ( string $name, callback $callback ) Adds a post-filter to a method.
before ( string $name, callback $callback ) Adds a pre-filter to a method.
clear ( string $key = null ) Unsets a variable. If no key is passed in, clear all variables.
get ( string $key = null ) : mixed Gets a variable.
handleError ( integer $errno, integer $errstr, integer $errfile, integer $errline ) Custom error handler. Converts errors into exceptions.
handleErrors ( boolean $enabled ) Enables/disables custom error handling.
handleException ( object $e ) Custom exception handler. Logs exceptions.
has ( string $key ) : boolean Checks if a variable has been set.
init ( ) Initializes the framework.
map ( string $name, callback $callback ) Maps a callback to a framework method.
path ( string $dir ) Adds a path for class autoloading.
register ( string $name, string $class, array $params = [], callback $callback = null ) Registers a class to a framework method.
set ( mixed $key, string $value = null ) Sets a variable.

Method Details

__call() public méthode

Handles calls to class methods.
public __call ( string $name, array $params ) : mixed
$name string Method name
$params array Method parameters
Résultat mixed Callback results

__construct() public méthode

Constructor.
public __construct ( )

_error() public méthode

Sends an HTTP 500 response for any errors.
public _error ( object $e )
$e object Thrown exception

_etag() public méthode

Handles ETag HTTP caching.
public _etag ( string $id, string $type = 'strong' )
$id string ETag identifier
$type string ETag type

_halt() public méthode

Stops processing and returns a given response.
public _halt ( integer $code = 200, string $message = '' )
$code integer HTTP status code
$message string Response message

_json() public méthode

Sends a JSON response.
public _json ( mixed $data, integer $code = 200, boolean $encode = true, string $charset = 'utf-8', integer $option )
$data mixed JSON data
$code integer HTTP status code
$encode boolean Whether to perform JSON encoding
$charset string Charset
$option integer Bitmask Json constant such as JSON_HEX_QUOT

_jsonp() public méthode

Sends a JSONP response.
public _jsonp ( mixed $data, string $param = 'jsonp', integer $code = 200, boolean $encode = true, string $charset = 'utf-8', integer $option )
$data mixed JSON data
$param string Query parameter that specifies the callback name.
$code integer HTTP status code
$encode boolean Whether to perform JSON encoding
$charset string Charset
$option integer Bitmask Json constant such as JSON_HEX_QUOT

_lastModified() public méthode

Handles last modified HTTP caching.
public _lastModified ( integer $time )
$time integer Unix timestamp

_notFound() public méthode

Sends an HTTP 404 response when a URL is not found.
public _notFound ( )

_redirect() public méthode

Redirects the current request to another URL.
public _redirect ( string $url, integer $code = 303 )
$url string URL
$code integer HTTP status code

_render() public méthode

Renders a template.
public _render ( string $file, array $data = null, string $key = null )
$file string Template file
$data array Template data
$key string View variable name

_route() public méthode

Routes a URL to a callback function.
public _route ( string $pattern, callback $callback, boolean $pass_route = false )
$pattern string URL pattern to match
$callback callback Callback function
$pass_route boolean Pass the matching route object to the callback

_start() public méthode

Starts the framework.
public _start ( )

_stop() public méthode

Stops the framework and outputs the current response.
public _stop ( integer $code = 200 )
$code integer HTTP status code

after() public méthode

Adds a post-filter to a method.
public after ( string $name, callback $callback )
$name string Method name
$callback callback Callback function

before() public méthode

Adds a pre-filter to a method.
public before ( string $name, callback $callback )
$name string Method name
$callback callback Callback function

clear() public méthode

Unsets a variable. If no key is passed in, clear all variables.
public clear ( string $key = null )
$key string Key

get() public méthode

Gets a variable.
public get ( string $key = null ) : mixed
$key string Key
Résultat mixed

handleError() public méthode

Custom error handler. Converts errors into exceptions.
public handleError ( integer $errno, integer $errstr, integer $errfile, integer $errline )
$errno integer Error number
$errstr integer Error string
$errfile integer Error file name
$errline integer Error file line number

handleErrors() public méthode

Enables/disables custom error handling.
public handleErrors ( boolean $enabled )
$enabled boolean True or false

handleException() public méthode

Custom exception handler. Logs exceptions.
public handleException ( object $e )
$e object Thrown exception

has() public méthode

Checks if a variable has been set.
public has ( string $key ) : boolean
$key string Key
Résultat boolean Variable status

init() public méthode

Initializes the framework.
public init ( )

map() public méthode

Maps a callback to a framework method.
public map ( string $name, callback $callback )
$name string Method name
$callback callback Callback function

path() public méthode

Adds a path for class autoloading.
public path ( string $dir )
$dir string Directory path

register() public méthode

Registers a class to a framework method.
public register ( string $name, string $class, array $params = [], callback $callback = null )
$name string Method name
$class string Class name
$params array Class initialization parameters
$callback callback Function to call after object instantiation

set() public méthode

Sets a variable.
public set ( mixed $key, string $value = null )
$key mixed Key
$value string Value

Property Details

$dispatcher protected_oe property

Event dispatcher.
protected object $dispatcher
Résultat object

$loader protected_oe property

Class loader.
protected object $loader
Résultat object

$vars protected_oe property

Stored variables.
protected array $vars
Résultat array