Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Hi Symfony community,

I recently extracted a small bundle from a project I work on and would like feedback on the design.

The idea is to keep using Symfony Forms as the request handling layer, but with a controller argument experience closer to Symfony's request mapping attributes.

Example:

public function create(
    #[MapRequestToForm]
    Post $post,
): JsonResponse {
    // $post is submitted and validated through the resolved form type.
}

It supports:

  • resolving the form type from data_class
  • submitting into objects already resolved by Symfony/Doctrine
  • combining with attributes like MapEntity
  • returning FormInterface instead of form data when needed
  • JSON/form requests
  • validation failure handling
  • a mapper service for manual usage

GitHub: https://github.com/azyouness/request-to-form-bundle

Packagist: https://packagist.org/packages/azyouness/request-to-form-bundle

Update: I wrote a longer article explaining where the idea came from and how the bundle works:
https://dev.to/azyouness/using-symfony-forms-as-controller-arguments-with-maprequesttoform-52ol

I would appreciate feedback on:

  • whether the attribute/resolver/listener design makes sense
  • whether this fits Symfony conventions
  • edge cases I may be missing
  • naming/API improvements before the package evolves further

Thanks.

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.