Darken\Attributes\QueryParam

class

An attribute that marks a property to be populated from the query string (e.g., ?foo=bar). If a custom $name is provided, that query parameter name will be used. Otherwise, the property’s name is used by default.

Example usage:

#[QueryParam('search')]
public string $searchQuery;

// Here, if the URL is: /products?search=keyword
// The property $searchQuery will be populated with "keyword".

#[QueryParam]
public int $page;

// If the URL is: /products?page=2
// The property $page is automatically populated with 2 (assuming type casting).

Methods

Method Details

public __construct (?string $name) QueryParam.php#37
$name ?string