-
Notifications
You must be signed in to change notification settings - Fork 2
TextResponse
Viames Marino edited this page Apr 22, 2026
·
2 revisions
Pair\Http\TextResponse is the explicit plain-text response object for Pair v4.
Use it when an endpoint must return raw text instead of JSON or HTML, for example webhook challenge handshakes.
new TextResponse(string $content, int $httpCode = 200, string $contentType = 'text/plain; charset=utf-8')
Arguments:
-
content: response body -
httpCode: HTTP status code -
contentType: response content type header
Example:
use Pair\Http\TextResponse;
return new TextResponse('challenge-token');-
send()sets theContent-Typeheader and the HTTP status code, then prints the text body. - When
APP_DEBUG=trueand observability debug headers are enabled,send()also emits Pair correlation and trace timing headers. -
TextResponseimplementsPair\Http\ResponseInterface, so it works with the same runtime dispatch path asJsonResponseandPageResponse.
See also: API, ApiController, Controller, ResponseInterface, ApiErrorResponse, Observability, EmptyResponse.