HTTP Response
The documentation is constantly evolving and updated alongside the project's progress. Since it is developed in parallel with the code, some sections may temporarily refer to earlier versions of the system-these are gradually adapted to the current state of the application. If you notice any outdated information, please report it or open an Issue / Pull Request.
Documentation
# HTTP Response
Controllers and middleware return Psr\Http\Message\ResponseInterface. The framework's Dbm\Http\Message\Response implements the extended response contract and provides convenience factories.
# Create common responses
use Dbm\Http\Message\Response;
return Response::html('<h1>Welcome</h1>');
return Response::json(['status' => 'ok']);
return Response::redirect('/account');
The constructor accepts a status code, headers, and optional body stream. PSR-7 methods such as withStatus(), withHeader(), and getBody() follow the immutable-message model: methods that change a message return a new instance.
Response::text(), html(), json(), download(), and redirect() create common response types. JSON encoding uses JSON_THROW_ON_ERROR; invalid data can raise an exception and should be handled by the application exception pipeline. A response emitter writes the returned response to the client.
For JSON API envelopes, use ApiResponder where that convention fits. BaseApiController::jsonResponse() remains available for custom payloads.