Marwa\Framework\Controllers\Controller is the framework base controller for application code.
request(?string $key = null, mixed $default = null): mixedinput(?string $key = null, mixed $default = null): mixedvalidate(array $rules, array $messages = [], array $attributes = [], ?ServerRequestInterface $request = null): arrayvalidated(FormRequest $request): arrayview(string $template, array $data = [], int $status = 200, array $headers = []): ResponseInterfacerender(string $template, array $data = []): stringjson(array|JsonSerializable $data, int $status = 200, array $headers = []): ResponseInterfaceresponse(string $body = '', int $status = 200, array $headers = []): ResponseInterfaceredirect(string $uri, int $status = 302, array $headers = []): ResponseInterfaceback(int $status = 302, array $headers = []): ResponseInterfaceflash(string $key, mixed $value): staticwithInput(?array $input = null): staticwithErrors(array|ErrorBag $errors): staticold(?string $key = null, mixed $default = null): mixedsession(?string $key = null, mixed $default = null): mixedunauthorized(string $message = 'Unauthorized'): ResponseInterfaceforbidden(string $message = 'Forbidden'): ResponseInterfaceabortIf(bool $condition, string $message = 'Forbidden', int $status = 403): ?ResponseInterfaceabortUnless(bool $condition, string $message = 'Forbidden', int $status = 403): ?ResponseInterfaceauthorize(string $ability, mixed $resource = null): boolauthorizeTo(string $ability, mixed $resource = null): voidcan(string $ability, mixed $resource = null): boolcannot(string $ability, mixed $resource = null): boolback() only honors safe referrers. Relative URLs are allowed, and absolute URLs must match the current request origin. Unsafe or missing referrers fall back to the current request URI, then /.
Policy-based authorization is provided by Marwa\Framework\Controllers\Concerns\AuthorizesRequests, which the base controller includes.
final class PostController extends Controller
{
public function show(int $id): ResponseInterface
{
return $this->view('posts/show', [
'post' => $id,
]);
}
}
The controller assumes the framework application container is available, so request, session, view, and validation helpers resolve from the shared runtime.