mini\Controller\Attributes\Route class

Documentation

Route attribute for controller methods

Maps a controller method to an HTTP route pattern. This is syntactic sugar over manual $this->router->get() calls.

Example:

#[Route('/', method: 'GET')]
public function index(): ResponseInterface
{
    return $this->respond(['users' => []]);
}

#[Route('/{id}/', method: 'GET')]
public function show(int $id): ResponseInterface
{
    $user = table(User::class)->find($id);
    if (!$user) throw new \mini\Exceptions\NotFoundException();
    return $this->respond($user);
}

Properties (2)

public string $path
public ?string $method

Methods (1)

Documentation missing

Source

src/Controller/Attributes/Route.php:31-37