slimphp / Slim-Psr7

PSR-7 implementation for use with Slim 4
MIT License
133 stars 45 forks source link

Add body parsing functionality in Request object #97

Open l0gicgate opened 5 years ago

l0gicgate commented 5 years ago

Currently we do not parse any incoming data in the Request object. All that functionality has been moved to the Slim-Http decorators repository.

We should by default at least support the incoming form data in the $_POST object and JSON.

dominikzogg commented 5 years ago

$body = (new StreamFactory())->createStreamFromFile('php://input');

l0gicgate commented 5 years ago

$body = (new StreamFactory())->createStreamFromFile('php://input');

We need to do this in addition to parsing the bodies different content types.

dominikzogg commented 5 years ago

@l0gicgate i try to create a PR, but its hard to test (php://input) is not writeable

dominikzogg commented 5 years ago

@l0gicgate adding php://input and use it for parsed body are two topics, please fix one after the other, cause parsed body from php://input it not a hard requirement for psr-message

l0gicgate commented 5 years ago

@dominikzogg I'm fine with adding a stream wrapper dev dependency like https://packagist.org/packages/mikey179/vfsStream for unit testing so we can wrap it and test it.

dominikzogg commented 5 years ago

@l0gicgate i didn't find any working example mocking php://input with vfsStream

dominikzogg commented 5 years ago

https://github.com/slimphp/Slim-Psr7/pull/110

dominikzogg commented 5 years ago

https://github.com/slimphp/Slim-Psr7/pull/110/files#diff-ea033125b85265ce3adf4e102a8d58bbR117

odan commented 4 months ago

Slim 4 has this feature already included in the BodyParsingMiddleware: https://github.com/slimphp/Slim/blob/4.x/Slim/Middleware/BodyParsingMiddleware.php

Do we really want to maintain the same feature 3 times? (1. slim/slim, 2. slim/http and now also in 3. slim/psr7)