We use guzzle integration of PSR-7 so read the PSR-7 docs first please it contains almost everything you need to know.
Instead of Psr\Http\Message\ServerRequestInterface
and Psr\Http\Message\ResponseInterface
use Apitte\Core\Http\ApiRequest
and Apitte\Core\Http\ApiResponse
in type hints. They add some additional methods.
Simple static helpers which help you with frequently used response modifications
- Sets headers required to recognize file properly
- Disables caching of given response
- See guzzle/psr7 docs for available streams
use Apitte\Core\Adjuster\FileResponseAdjuster;
use Contributte\Psr7\Psr7ResponseFactory;
use function GuzzleHttp\Psr7\stream_for;
$response = Psr7ResponseFactory::fromGlobal();
$stream = stream_for(fopen('/tmp/test.json', 'r+'));
$response = FileResponseAdjuster::adjust($response, $stream, 'filename.json', 'application/json');