class RouteBlueprint (View source)

Provide a fluent interface for registering routes with the router.

Traits

Represent an object which has an array of attributes.

Methods

mixed
getAttribute(string $attribute, mixed $default = '')

Get attribute.

array
getAttributes()

Get all attributes.

void
setAttribute(string $attribute, mixed $value)

Set attribute.

attribute(string $attribute, mixed $value)

Fluent alias for setAttribute().

void
setAttributes(array $attributes)

Set all attributes.

attributes(array $attributes)

Fluent alias for setAttributes().

__construct(Router $router, ViewService $view_service)

Constructor.

methods(string[] $methods)

Match requests using one of the specified methods.

url(string $url, array $where = [])

Set the condition attribute to a URL.

where($condition)

Set the condition attribute.

middleware(string|string[] $middleware)

Set the middleware attribute.

setNamespace(string $namespace)

Set the namespace attribute.

query(callable $query)

Set the query attribute.

name(string $name)

Set the name attribute.

void
group(Closure|string $routes)

Create a route group.

void
handle(string|Closure $handler = '')

Create a route.

void
view(string|string[] $views)

Handle a request by directly rendering a view.

void
all(string|Closure $handler = '')

Match ALL requests.

get()

Match requests with a method of GET or HEAD.

post()

Match requests with a method of POST.

put()

Match requests with a method of PUT.

patch()

Match requests with a method of PATCH.

delete()

Match requests with a method of DELETE.

options()

Match requests with a method of OPTIONS.

any()

Match requests with any method.

Details

mixed getAttribute(string $attribute, mixed $default = '')

Get attribute.

Parameters

string $attribute
mixed $default

Return Value

mixed

array getAttributes()

Get all attributes.

Return Value

array mixed>

void setAttribute(string $attribute, mixed $value)

Set attribute.

Parameters

string $attribute
mixed $value

Return Value

void

HasAttributesTrait attribute(string $attribute, mixed $value)

Fluent alias for setAttribute().

Parameters

string $attribute
mixed $value

Return Value

HasAttributesTrait $this

void setAttributes(array $attributes)

Set all attributes.

No attempt to merge attributes is done - this is a direct overwrite operation.

Parameters

array $attributes mixed> $attributes

Return Value

void

HasAttributesTrait attributes(array $attributes)

Fluent alias for setAttributes().

Parameters

array $attributes mixed> $attributes

Return Value

HasAttributesTrait $this

__construct(Router $router, ViewService $view_service)

Constructor.

Parameters

Router $router
ViewService $view_service

RouteBlueprint methods(string[] $methods)

Match requests using one of the specified methods.

Parameters

string[] $methods

Return Value

RouteBlueprint $this

RouteBlueprint url(string $url, array $where = [])

Set the condition attribute to a URL.

Parameters

string $url
array $where string> $where

Return Value

RouteBlueprint $this

RouteBlueprint where($condition)

Set the condition attribute.

Parameters

$condition

Return Value

RouteBlueprint $this

RouteBlueprint middleware(string|string[] $middleware)

Set the middleware attribute.

Parameters

string|string[] $middleware

Return Value

RouteBlueprint $this

RouteBlueprint setNamespace(string $namespace)

Set the namespace attribute.

This should be renamed to namespace for consistency once minimum PHP version is increased to 7+.

Parameters

string $namespace

Return Value

RouteBlueprint $this

RouteBlueprint query(callable $query)

Set the query attribute.

Parameters

callable $query

Return Value

RouteBlueprint $this

RouteBlueprint name(string $name)

Set the name attribute.

Parameters

string $name

Return Value

RouteBlueprint $this

void group(Closure|string $routes)

Create a route group.

Parameters

Closure|string $routes Closure or path to file.

Return Value

void

void handle(string|Closure $handler = '')

Create a route.

Parameters

string|Closure $handler

Return Value

void

void view(string|string[] $views)

Handle a request by directly rendering a view.

Parameters

string|string[] $views

Return Value

void

void all(string|Closure $handler = '')

Match ALL requests.

Parameters

string|Closure $handler

Return Value

void

RouteBlueprint get()

Match requests with a method of GET or HEAD.

Return Value

RouteBlueprint $this

RouteBlueprint post()

Match requests with a method of POST.

Return Value

RouteBlueprint $this

RouteBlueprint put()

Match requests with a method of PUT.

Return Value

RouteBlueprint $this

RouteBlueprint patch()

Match requests with a method of PATCH.

Return Value

RouteBlueprint $this

RouteBlueprint delete()

Match requests with a method of DELETE.

Return Value

RouteBlueprint $this

RouteBlueprint options()

Match requests with a method of OPTIONS.

Return Value

RouteBlueprint $this

RouteBlueprint any()

Match requests with any method.

Return Value

RouteBlueprint $this