precision-soft/symfony-json-form
A Symfony package for working with JSON-driven forms, helping you define, validate, and process form data from JSON schemas within Symfony applications. It integrates with Symfony’s Form component and offers a lightweight way to handle JSON form configurations.
.example/ – a runnable product editor that demonstrates every element type, three form services, a value object built through context hooks, and React rendering with both formV1 and formV2. Read .example/README.md first..dev/validate/all.sh --example to see the full flow.AbstractFormService subclass for a simple form (e.g., a product with name and price), define a DTO, and wire handleRequest() to populate it from a request and render() to output JSON for the React components.AbstractFormService. Override hasJsonBody() to control JSON detection (defaults to inspecting the request content type) and constructDto() to customise DTO instantiation.handleRequest() decodes JSON bodies and denormalises them with the correct format, so JavaScript clients sending whole numbers (e.g. 150 for a float property) work out of the box. GET and form-encoded requests are still denormalised without a format.render() produces the JSON consumed by the React components. It accepts a DTO instance or a subclass of the expected DTO (since v1.3.0 the guard uses instanceof). If the DTO cannot be constructed without arguments, it throws the package’s Exception with formName and dtoClass context, wrapping the original ArgumentCountError..example/) when your form data needs richer types than scalars.import type because assets/react/tsconfig.json sets verbatimModuleSyntax. The example renders the same JSON with both formV1 and formV2, deriving initial values from it — copy that pattern for your own forms.precision-soft/symfony-phpunit (AbstractTestCase, MockDto) and a Mockery double of the Symfony Serializer. If you write similar tests, mirror that setup; phpstan/phpstan-mockery is available as a dev dependency.Content-Type (e.g. application/vnd.api+json), override hasJsonBody(). When JSON is detected, the serializer receives the json format; otherwise it gets none — this matters for numeric type coercion.handleRequest() and render() now accept subclasses via instanceof. A DTO of an unrelated class still raises the original exception with the same context. Pass a subclass only when you intentionally want to populate in place.render() wraps constructor errors in the package Exception. Catch it to surface a clear message (formName, dtoClass) instead of a raw ArgumentCountError.verbatimModuleSyntax enabled, a type-only import written without import type will fail the typecheck. Also ensure your bundler elides unused imports if you compile the sources yourself.export-ignored – It won’t be present in a production install. Use it from the repository as a reference; don’t rely on it at runtime.precision-soft/symfony-phpunit v3.7.0 and phpstan/phpstan-mockery. These are only needed for development; they are not runtime requirements.How can I help you explore Laravel packages today?