Darken\Attributes\RouteParam

class

An attribute that maps a route parameter (e.g., {id} in a route like /users/{id}) to the annotated property in a class. If a custom $name is provided, that route parameter name will be used. Otherwise, the property’s own name will be used by default. This can be especially helpful when the route parameter name does not match the property name you wish to use in your code.

Example usage:

// Given a route: /users/{id}

#[RouteParam('id')]
public string $userId;

// The route param "id" is thus mapped to $userId,
// which can be more descriptive within your codebase.

Methods

Method Details

public __construct (?string $name) RouteParam.php#35
$name ?string