Contributte Apitte-core
We use guzzle (opens new window) integration of PSR-7 (opens new window) so read the PSR-7 docs (opens new window) 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.
# Response adjusters
Simple static helpers which help you with frequently used response modifications
# FileResponseAdjuster
- Sets headers required to recognize file properly
- Disables caching of given response
- See guzzle/psr7 docs (opens new window) 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');
1
2
3
4
5
6
7
2
3
4
5
6
7