# Controller

Namespace Chevere\Controller

The Controller component is a special type of Action in charge of handling incoming instructions. Its run method only takes parameters of type string.

Controller is intended to use them wired to:

# Defining a Controller

A Controller implements the Interfaces\ControllerInterface. You can extend Controller to quick create a compliant Controller:

use Chevere\Controller\Controller;

final class SomeController extends Controller
{
    // ...
}

# Run Parameters

Parameters are defined in the run method, same as an Action, but it just takes strings.

public function run(string $pepito, string $paysTwice): array
{
    // ...
}

# Parameter Attribute

Use StringAttribute to hint run parameters. This enables to validate these parameters against a Regex match when using the getResponse method.

use Chevere\Attribute\StringAttribute;

public function run(
    #[StringAttribute('/^[a-z]$/')]
    string $pepito,
    #[StringAttribute('/^[a-zA-Z]+$/', 'What it does')]
    string $paysTwice
): array
{
    // ...
}