DEV Community

Discussion on: Integrate Symfony form with Vuejs

Collapse
zspine profile image
M#3

Interesting... Phase 1 seems to be the correct approach to migrate the code base to vuejs without refactoring the entire code base at once.

Phase 2: I am not quite sure, I prefer to work with json and keep the front-end forms decoupled from back-end dependency and for larger projects I use API Platform with vuejs.

Collapse
yellow1912 profile image
yellow1912 Author • Edited on

You are absolutely right regarding APIs for phase 2. At the moment we still have an internal debate on how this should be handled because the main frontend code we have right now is the backend control. It's so much easier to dynamically configure the form on the server code (Symfony) and with Validation and ORM components the post-processing is taken care of for us in most cases. In the future though, API does seem like the way to go and eventually we will go that way.

How do you handle complex data with APIs? Restful APIs seem to be overkill (and with heavy overhead for nested data structure), while graphql does have its own issues.

Collapse
zspine profile image
M#3

Yes, I agree that in certain scenarios working with Symfony forms a much easier and a huge time saver. However, the API approach has its benefits when we are using Vue on the front-end. There is no much difference in post-processing compared to the traditional form handling and validation can be simplified a lot with Vue front-end.

Complex data? I am not sure what you mean by the complex nested data structure.

Anyway, don't try anything new on an existing codebase. You can do some experiments with a small scale project to understand the architecture and challenges.

Note: API Platform is a much better choice for REST API implementation but it's a bit overkill to implement it in an existing codebase. FOSRestBundle is better for gradual migration.