class Application extends Router (View source)

Properties

protected array $error_code

Define the functions related to an http code executed if this code is up

from  Router
protected array $middlewares

Define the global middleware

from  Router
protected string $prefix

Define the routing prefix

from  Router
protected string $special_method from  Router
protected array $current

Method Http current.

from  Router
protected bool $auto_csrf

Define the auto csrf check status.

from  Router
static protected array $routes

Route collection.

from  Router

Methods

__construct(Request $request, Response $response)

Application constructor

void
setBaseRoute(string $base_route)

Set the base route

from  Router
void
setAutoCsrf(bool $auto_csrf)

Set auto CSRF status Note: Disable only you run on test env

from  Router
prefix(string $prefix, callable $cb)

Add a prefix on the roads

from  Router
middleware(array $middlewares)

Allows to associate a global middleware on an route

from  Router
void
route(array $definition)

Route mapper

from  Router
any(string $path, callable|string|array $cb)

Add a route for

from  Router
get(string $path, callable|string|array $cb)

Add a GET route

from  Router
post(string $path, callable|string|array $cb)

Add a POST route

from  Router
delete(string $path, callable|string|array $cb)

Add a DELETE route

from  Router
put(string $path, callable|string|array $cb)

Add a PUT route

from  Router
patch(string $path, callable|string|array $cb)

Add a PATCH route

from  Router
options(string $path, callable|string|array $cb)

Add a OPTIONS route

from  Router
code(int $code, callable|array|string $cb)

Launch a callback function for each HTTP error code.

from  Router
match(array $methods, string $path, callable|string|array $cb)

Match route de tout type de method

from  Router
string
getSpecialMethod()

Retrieve the define special method

from  Router
bool
hasSpecialMethod()

Check user define the special method

from  Router
array
getRoutes()

Get the route collection

from  Router
getContainer()

Get container

void
bind(Loader $config)

Configuration Association

static Application
make(Request $request, Response $response)

Build the application

bool
isRunningOnCli()

Check if is running on php cli

bool|null
send()

Launcher of the application

void
disablePoweredByMention()

Allows you to enable writing the X-Powered-By header in the answer of the inquiry.

rest(string $url, string|array $controller_name, array $where = [])

Make the REST API base on route and ressource controller.

void
abort(int $code = 500, string $message = '', array $headers = [])

Abort application

mixed
container(string|null $name = null, callable|null $callable = null)

Build dependance

mixed
__invoke(array ...$params)

__invoke

Details

__construct(Request $request, Response $response)

Application constructor

Parameters

Request $request
Response $response

void setBaseRoute(string $base_route)

Set the base route

Parameters

string $base_route

Return Value

void

void setAutoCsrf(bool $auto_csrf)

Set auto CSRF status Note: Disable only you run on test env

Parameters

bool $auto_csrf

Return Value

void

Router prefix(string $prefix, callable $cb)

Add a prefix on the roads

Parameters

string $prefix
callable $cb

Return Value

Router

Exceptions

Router middleware(array $middlewares)

Allows to associate a global middleware on an route

Parameters

array $middlewares

Return Value

Router

void route(array $definition)

Route mapper

Parameters

array $definition

Return Value

void

Exceptions

RouterException

Router any(string $path, callable|string|array $cb)

Add a route for

GET, POST, DELETE, PUT, OPTIONS, PATCH

Parameters

string $path
callable|string|array $cb

Return Value

Router

Exceptions

Route get(string $path, callable|string|array $cb)

Add a GET route

Parameters

string $path
callable|string|array $cb

Return Value

Route

Route post(string $path, callable|string|array $cb)

Add a POST route

Parameters

string $path
callable|string|array $cb

Return Value

Route

Route delete(string $path, callable|string|array $cb)

Add a DELETE route

Parameters

string $path
callable|string|array $cb

Return Value

Route

Route put(string $path, callable|string|array $cb)

Add a PUT route

Parameters

string $path
callable|string|array $cb

Return Value

Route

Route patch(string $path, callable|string|array $cb)

Add a PATCH route

Parameters

string $path
callable|string|array $cb

Return Value

Route

Route options(string $path, callable|string|array $cb)

Add a OPTIONS route

Parameters

string $path
callable|string|array $cb

Return Value

Route

Router code(int $code, callable|array|string $cb)

Launch a callback function for each HTTP error code.

When the define code match with response code.

Parameters

int $code
callable|array|string $cb

Return Value

Router

Router match(array $methods, string $path, callable|string|array $cb)

Match route de tout type de method

Parameters

array $methods
string $path
callable|string|array $cb

Return Value

Router

protected string getSpecialMethod()

Retrieve the define special method

Return Value

string

protected bool hasSpecialMethod()

Check user define the special method

Return Value

bool

array getRoutes()

Get the route collection

Return Value

array

Capsule getContainer()

Get container

Return Value

Capsule

void bind(Loader $config)

Configuration Association

Parameters

Loader $config

Return Value

void

static Application make(Request $request, Response $response)

Build the application

Parameters

Request $request
Response $response

Return Value

Application

bool isRunningOnCli()

Check if is running on php cli

Return Value

bool

bool|null send()

Launcher of the application

Return Value

bool|null

Exceptions

RouterException

void disablePoweredByMention()

Allows you to enable writing the X-Powered-By header in the answer of the inquiry.

Return Value

void

Application rest(string $url, string|array $controller_name, array $where = [])

Make the REST API base on route and ressource controller.

Parameters

string $url
string|array $controller_name
array $where

Return Value

Application

Exceptions

ApplicationException

void abort(int $code = 500, string $message = '', array $headers = [])

Abort application

Parameters

int $code
string $message
array $headers

Return Value

void

Exceptions

HttpException

mixed container(string|null $name = null, callable|null $callable = null)

Build dependance

Parameters

string|null $name
callable|null $callable

Return Value

mixed

Exceptions

ApplicationException

mixed __invoke(array ...$params)

__invoke

This point method on the container system

Parameters

array ...$params

Return Value

mixed

Exceptions

ApplicationException