adinan-cenci / psr-17
An implementation of the PSR-17 specification.
v1.0.8
2023-09-08 00:27 UTC
Requires
- adinan-cenci/psr-7: ^1.1.3
- psr/http-factory: ^1.0
Requires (Dev)
- phpunit/phpunit: 9.5.x-dev
This package is auto-updated.
Last update: 2024-11-08 03:00:36 UTC
README
This is an implementation of the PSR-17 specification.
Besides the psr methods, the factories also include some useful methods:
ResponseFactory
use AdinanCenci\Psr17\ResponseFactory; $responseFactory = new ResponseFactory(); // Returns an instance of Psr\Http\Message\ResponseInterface with // code 200 $factory->ok('your body here'); // 201 $factory->created('your body here'); // 301 $factory->movedPermanently('http://redirect.to'); // 302 $factory->movedTemporarily('http://redirect.to'); // 400 $factory->badRequest('your body here'); // 401 $factory->unauthorized('your body here'); // 403 $factory->forbidden('your body here'); // 404 $factory->notFound('your body here'); // 500 $factory->internalServerError('your body here'); // 501 $factory->notImplemented('your body here'); // 502 $factory->badGateway('your body here'); // 503 $factory->serviceUnavailable('your body here');
ServerRequestFactory
use AdinanCenci\Psr17\ServerRequestFactory; $requestFactory = new ServerRequestFactory(); // Creates an instance of Psr\Http\Message\ServerRequestInterface // out of the global values. $request = $requestFactory->createFromGlobals();
UploadedFileFactory
use AdinanCenci\Psr17\UploadedFileFactory; $filesFactory = new UploadedFileFactory(); // Will return the contents of $_FILES as // Psr\Http\Message\UploadedFileInterface instances. $files = $filesFactory->getFilesFromGlobals();
Licence
Mit