# 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 Attributes
Use Description and Regex attributes to hint run input parameters.
use Chevere\Attributes\Regex;
public function run(
#[Regex('/^[a-z]$/')]
string $pepito,
#[Regex('/^[a-zA-Z]+$/')]
string $paysTwice
): array
{
// ...
}