ApiResponseFactory
final class ApiResponseFactory (View source)
Creates the framework API envelope as immutable UTF-8 JSON responses.
Methods
__construct(Psr17Factory $responseFactory)
Uses one PSR-17 implementation for response and body stream creation.
json(mixed $data, int $status = HttpStatus::OK->value, array $meta = [])
Encodes data and optional metadata under the stable API response envelope.
ResponseInterface
ok(array $data, array $meta = [])
Creates a successful 200 response using the standard API envelope.
ResponseInterface
Details
__construct
__construct(Psr17Factory $responseFactory)
Uses one PSR-17 implementation for response and body stream creation.
json
ResponseInterface
json(mixed $data, int $status = HttpStatus::OK->value, array $meta = [])
Encodes data and optional metadata under the stable API response envelope.
ok
ResponseInterface
ok(array $data, array $meta = [])
Creates a successful 200 response using the standard API envelope.