Skip to content
docsv0.1.0

ControllerGenerator

Generates a controller extending {@see \Milpa\app\Providers\BaseController} with one routed method per `--methods` entry (`#[Route]`, `array $params = []`, `HttpResponse`). Follows the framework's controller convention exactly so `verify-controller.php` passes on the output.

ControllerGenerator::__construct()

public function __construct(Milpa\DevTools\Make\StubRenderer $renderer = new StubRenderer()):

Parameters

Parameters of __construct()
NameTypeDescription
$rendererMilpa\DevTools\Make\StubRenderer

ControllerGenerator::name()

public function name(): string

The `<what>` token this generator answers to: `'controller'`.

ControllerGenerator::generate()

public function generate(Milpa\DevTools\Make\GenerationContext $context): Milpa\DevTools\Make\GenerationResult

Renders the controller class + one `#[Route]`-attributed method per `--methods` entry.

Parameters

Parameters of generate()
NameTypeDescription
$contextMilpa\DevTools\Make\GenerationContext