softspring/form-schema

Extracts JSON-schema-like metadata from Symfony forms

Maintainers

Package info

github.com/softspring/form-schema

Type:component

pkg:composer/softspring/form-schema

Statistics

Installs: 0

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

6.0.x-dev 2026-06-05 08:17 UTC

This package is auto-updated.

Last update: 2026-06-05 08:20:58 UTC


README

Latest Stable Latest Unstable License PHP Version Downloads CI Coverage

softspring/form-schema extracts JSON-schema-like metadata from Symfony forms.

This package is still in active development. Its public API, extracted schema shape, and extension points may change before the first stable release.

What It Provides

  • Schema extraction from a Symfony FormInterface, form type class, or form type instance.
  • Field extractors for scalar fields, compound fields, collections, choices, and buttons.
  • Support for explicit json_schema and json_scheme form options.
  • Basic metadata extraction from labels, help text, defaults, and Symfony validator constraints.
  • A Symfony bundle that registers the extractor services and field extractor tags.

Installation

composer require softspring/form-schema:^6.0@dev

If Symfony Flex does not register the bundle automatically, add it manually:

// config/bundles.php
return [
    Softspring\Component\FormSchema\SfsFormSchemaBundle::class => ['all' => true],
];

Basic Usage

Inject SchemaExtractor and extract a schema from a form type:

use Softspring\Component\FormSchema\Schema\SchemaExtractor;

final class ExampleService
{
    public function __construct(private SchemaExtractor $schemaExtractor)
    {
    }

    public function schema(): array
    {
        return $this->schemaExtractor->extract(ExampleFormType::class);
    }
}

You can also pass a resolved FormInterface when the form must be created with application-specific options.

Custom Field Extractors

Create a service implementing FieldSchemaExtractorInterface and tag it with softspring.form_schema.field_extractor.

Extractors are evaluated in service order. Return true from supports() only for the fields your extractor owns.

Contributing

See CONTRIBUTING.md.

Report issues and send Pull Requests

Security

See SECURITY.md.

License

This package is free and released under the AGPL-3.0 license.