Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSR HTTP message converters for controllers #89

Merged
merged 1 commit into from
Feb 17, 2021

Conversation

derrabus
Copy link
Member

This PR proposes to add two classes to symfony/psr-http-message-bridge that have been removed from sensio/framework-extra-bundle.

By adding PsrServerRequestResolver and PsrResponseListener to its service container, with autowring and autoconfiguring enabled, an application gains the ability to operate controllers on PSR-7 message objects instead of HttpFoundation.

This is especially useful if a developer wants to reuse generic packages like league/oauth2-server.

Configuration files for autowiring the two classes can be provided as Flex recipes.

Comment on lines +54 to +61
$container->services()
->set('nyholm.psr_factory', Psr17Factory::class)
->alias(ResponseFactoryInterface::class, 'nyholm.psr_factory')
->alias(ServerRequestFactoryInterface::class, 'nyholm.psr_factory')
->alias(StreamFactoryInterface::class, 'nyholm.psr_factory')
->alias(UploadedFileFactoryInterface::class, 'nyholm.psr_factory')
;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 The recipe for nyholm/psr7 provides this piece of configuration already.

Comment on lines +62 to +69
$container->services()
->defaults()->autowire()->autoconfigure()
->set(HttpFoundationFactoryInterface::class, HttpFoundationFactory::class)
->set(HttpMessageFactoryInterface::class, PsrHttpFactory::class)
->set(PsrResponseListener::class)
->set(PsrServerRequestResolver::class)
;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 A new recipe for psr-http-message-bridge should provide this piece of configuration.

@derrabus derrabus force-pushed the improvement/message-conversion branch from 2cf933e to ed9e273 Compare February 16, 2021 14:04
@derrabus
Copy link
Member Author

derrabus commented Feb 16, 2021

CI failure is unrelated. I'll work on a separate PR to upgrade the CI for the year 2021. 😃

/edit: #90

@derrabus derrabus force-pushed the improvement/message-conversion branch 2 times, most recently from 2068ce5 to 2ca0157 Compare February 16, 2021 15:28
@derrabus
Copy link
Member Author

Recipe: symfony/recipes#899

@derrabus derrabus force-pushed the improvement/message-conversion branch from 2ca0157 to d5ecc48 Compare February 16, 2021 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants