Neuron-PHP

Route

Base route attribute for defining HTTP routes on controller methods.

This attribute allows routes to be defined directly on controller methods, providing a modern alternative to YAML-based route configuration.

Tags
example
#[Route('/users/:id', method: 'GET', name: 'users.show', filters: ['auth'])]
public function show(int $id) {
    // Implementation
}
Attributes
#[Attribute]
\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE

Table of Contents

Properties

$filters  : array<string|int, mixed>
$method  : string
$name  : string|null
$path  : string

Methods

__construct()  : mixed
getFilters()  : array<string|int, mixed>
Get the filters
getMethod()  : string
Get the HTTP method
getName()  : string|null
Get the route name
getPath()  : string
Get the route path

Properties

$filters read-only

public array<string|int, mixed> $filters = []

$method read-only

public string $method = 'GET'

$name read-only

public string|null $name = null

$path read-only

public string $path

Methods

__construct()

public __construct(string $path[, string $method = 'GET' ][, string|null $name = null ][, array<string|int, mixed> $filters = [] ]) : mixed
Parameters
$path : string

The route path (e.g., '/users/:id')

$method : string = 'GET'

HTTP method (GET, POST, PUT, DELETE)

$name : string|null = null

Optional route name for URL generation

$filters : array<string|int, mixed> = []

Array of filter names to apply to this route

getFilters()

Get the filters

public getFilters() : array<string|int, mixed>
Return values
array<string|int, mixed>

getMethod()

Get the HTTP method

public getMethod() : string
Return values
string

getName()

Get the route name

public getName() : string|null
Return values
string|null

getPath()

Get the route path

public getPath() : string
Return values
string

        
On this page

Search results