\Piko\FastApplication

This class implements a fast and simple route handlers application

Properties summary

Name Description
private $router  

Inherited Properties

Name Description
public $basePath The absolute base path of the application.
public $behaviors Behaviors container.
public $components The components container
public $defaultLayout The default layout name without file extension.
public $defaultLayoutPath The default layout path. An alias could be used.
public $errorHandler  
public $errorRoute The Error route to display exceptions in a friendl…
public $language The language that is meant to be used for end user…
protected $eventDispatcher  
protected $listenerProvider  
protected $pipeline  

Methods summary

Name Description
public createResponse Helper to create a response
public getRouter Return a router instance
public listen Register a route handler
public run Run the application.

Inherited Methods

Name Description
public __call Magic method to call a behavior.
public __construct Constructor
public attachBehavior Attach a behavior to the class instance.
public detachBehavior Detach a behavior.
public getComponent Retrieve a unique instance of a registered compone…
public handle {@inheritDoc}
public on Registers an event listener.
public pipe Add a middleware in the application pipeline queue…
public run Run the application.
public trigger Trigger an event that may be listen by event liste…

Properties

private $router : \Piko\Router


Methods

public createResponse(): \HttpSoft\Message\Response

public static  createResponse(string  $body = ''): \HttpSoft\Message\Response

Helper to create a response

Parameters

$body (default: ‘’): The response body

Return:

\HttpSoft\Message\Response


public getRouter(): \Piko\Router

public  getRouter(): \Piko\Router

Return a router instance

Return:

\Piko\Router


public listen(): void

public  listen(string|string[]  $requestMethod, string  $path, callable  $handler): void

Register a route handler

Parameters

$requestMethod : The allowed request(s) method(s)

$path : The route path

$handler : A callable handler, which have the following signature:

function(Psr\Http\Message\ServerRequestInterface $request): string|Psr\Http\Message\ResponseInterface

public run(): void

public  run(\Psr\Http\Message\ServerRequestInterface  $request = null, bool  $emitHeaders = true): void

Run the application.

Parameters

$request (default: null):

$emitHeaders (default: true): Controls whether headers will be emmited (header() function called)