assouan/controller

HTTP controller base class for the A PHP libraries.

Maintainers

Package info

github.com/assouan/controller

pkg:composer/assouan/controller

Statistics

Installs: 0

Dependents: 2

Suggesters: 0

Stars: 0

dev-main / 0.1.x-dev 2026-06-21 10:11 UTC

This package is auto-updated.

Last update: 2026-06-21 10:11:47 UTC


README

HTTP controller base class for the A PHP libraries.

composer require assouan/controller

Requires PHP 8.5 or later.

Input

Controller method arguments are resolved by name from route attributes, query string, form bodies, and JSON bodies.

class Search extends A\Http\Controller
{
    public function get(string $q = ''): array
    {
        return ['q' => $q];
    }

    public function post(string $message): array
    {
        return ['message' => $message];
    }
}

Input priority is:

  • route attributes
  • application/x-www-form-urlencoded body
  • application/json body
  • query string

Missing nullable arguments stay null; scalar arguments are cast to their declared type.

Rendering

Action return values are rendered with a small default:

return new A\Http\Response();       // used as-is
return ['ok' => true];              // JSON response
return (object)['ok' => true];      // JSON response
return '<h1>Hello</h1>';            // HTML response
return null;                        // empty response