PHP Class Phprest\Application

Inheritance: implements Symfony\Component\HttpKernel\HttpKernelInterface, implements Symfony\Component\HttpKernel\TerminableInterface, implements League\Container\ContainerAwareInterface, implements League\Event\ListenerAcceptorInterface, use trait League\Event\EmitterTrait, use trait League\Container\ContainerAwareTrait, use trait Phprest\Service\Hateoas\Getter, use trait Phprest\Service\Hateoas\Util, use trait Phprest\Service\Logger\Getter
Show file Open project: phprest/phprest Class Usage Examples

Protected Properties

Property Type Description
$configuration Config
$exceptionDecorator callable
$router League\Route\RouteCollection
$stackBuilder Stack\Builder

Public Methods

Method Description
__construct ( Config $configuration )
delete ( string $route, mixed $action ) : void Add a DELETE route.
get ( string $route, mixed $action ) : void Add a GET route.
getConfiguration ( ) : Config
getEventEmitter ( ) : League\Event\EmitterInterface Return the event emitter.
getRouter ( ) : RouteCollection
handle ( Request $request, integer $type = self::MASTER_REQUEST, boolean $catch = true ) : Response Handle the request.
head ( string $route, mixed $action ) : void Add a HEAD route
options ( string $route, mixed $action ) : void Add a OPTIONS route
patch ( string $route, mixed $action ) : void Add a PATCH route.
post ( string $route, mixed $action ) : void Add a POST route.
put ( string $route, mixed $action ) : void Add a PUT route.
registerController ( string $class ) : void
registerMiddleware ( string $classPath, array $arguments = [] )
registerService ( Phprest\Service\Serviceable $service, Phprest\Service\Configurable $config ) : void
run ( Request $request = null ) : string Run the application
setExceptionDecorator ( callable $func ) : void Set the exception decorator.
subscribe ( string $event, callable $listener, integer $priority = ListenerAcceptorInterface::P_NORMAL ) Subscribe to an event.
terminate ( Request $request, Response $response ) : void Terminates a request/response cycle.

Protected Methods

Method Description
setErrorHandler ( ) : void

Method Details

__construct() public method

public __construct ( Config $configuration )
$configuration Config

delete() public method

Add a DELETE route.
public delete ( string $route, mixed $action ) : void
$route string
$action mixed
return void

get() public method

Add a GET route.
public get ( string $route, mixed $action ) : void
$route string
$action mixed
return void

getConfiguration() public method

public getConfiguration ( ) : Config
return Config

getEventEmitter() public method

Return the event emitter.
public getEventEmitter ( ) : League\Event\EmitterInterface
return League\Event\EmitterInterface

getRouter() public method

public getRouter ( ) : RouteCollection
return Phprest\Router\RouteCollection

handle() public method

Handle the request.
public handle ( Request $request, integer $type = self::MASTER_REQUEST, boolean $catch = true ) : Response
$request Symfony\Component\HttpFoundation\Request
$type integer
$catch boolean
return Symfony\Component\HttpFoundation\Response

head() public method

Add a HEAD route
public head ( string $route, mixed $action ) : void
$route string
$action mixed
return void

options() public method

Add a OPTIONS route
public options ( string $route, mixed $action ) : void
$route string
$action mixed
return void

patch() public method

Add a PATCH route.
public patch ( string $route, mixed $action ) : void
$route string
$action mixed
return void

post() public method

Add a POST route.
public post ( string $route, mixed $action ) : void
$route string
$action mixed
return void

put() public method

Add a PUT route.
public put ( string $route, mixed $action ) : void
$route string
$action mixed
return void

registerController() public method

public registerController ( string $class ) : void
$class string Namespaced class name
return void

registerMiddleware() public method

public registerMiddleware ( string $classPath, array $arguments = [] )
$classPath string
$arguments array

registerService() public method

public registerService ( Phprest\Service\Serviceable $service, Phprest\Service\Configurable $config ) : void
$service Phprest\Service\Serviceable
$config Phprest\Service\Configurable
return void

run() public method

Run the application
public run ( Request $request = null ) : string
$request Symfony\Component\HttpFoundation\Request
return string

setErrorHandler() protected method

protected setErrorHandler ( ) : void
return void

setExceptionDecorator() public method

Set the exception decorator.
public setExceptionDecorator ( callable $func ) : void
$func callable
return void

subscribe() public method

Subscribe to an event.
public subscribe ( string $event, callable $listener, integer $priority = ListenerAcceptorInterface::P_NORMAL )
$event string
$listener callable
$priority integer

terminate() public method

Terminates a request/response cycle.
public terminate ( Request $request, Response $response ) : void
$request Symfony\Component\HttpFoundation\Request
$response Symfony\Component\HttpFoundation\Response
return void

Property Details

$configuration protected property

protected Config,phprest $configuration
return Config

$exceptionDecorator protected property

protected callable $exceptionDecorator
return callable

$router protected property

protected RouteCollection,League\Route $router
return League\Route\RouteCollection

$stackBuilder protected property

protected Builder,Stack $stackBuilder
return Stack\Builder