Search by

coolms / field-bundle

coolms

Symfony integration for coolms/field: the bundle and its extension, the field-definition API Platform surface, the console commands, form types, validation registry and the override storage router

Package info

github.com/coolms/field-bundle

Type:symfony-bundle

pkg:composer/coolms/field-bundle

Statistics

Installs: 11

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 1

v2.0.0-alpha3 2026-10-16 21:32 UTC

README

Symfony wiring for the field family: the bundle, its DI extension, the console commands, form types, the override storage router, and the field-definition API Platform resources.

composer require coolms/field-bundle:^2.0@alpha

Only pre-releases exist so far, hence the @alpha stability flag. Requiring this pulls in coolms/field and coolms/field-doctrine, so it is the only one of the three you name directly.

// config/bundles.php
CoolMS\Field\Bundle\FieldBundle::class => ['all' => true],

What the extension registers

  • Doctrine mapping for CoolMS\Field\Entity, pointed at coolms/field-doctrine's XML, on an entity manager named central -- the application needs DoctrineBundle with an entity manager of that name -- and DefinitionInterface resolved to Definition
  • the definition repository, aliased to the domain's contract
  • coolms:field:definition:create, coolms:field:definition:list and coolms:field:prune-undeclared
  • the cache warmer that imports the fields declared in configuration
  • the built-in form types and the override storage router
  • the API surface: the resources /field/definitions (with /{id}, /reorder and the delete by alias), /field/form-types and /dynamic-entity/constraints, with every state provider and processor they name, the label writer they use and the constraint registry

An application that installs the bundle serves those routes without registering any of this package's classes itself. Since API Platform 4.1 a class carrying #[ApiResource] is found by being an autoconfigured service, so the extension registers each resource as one.

Fields declared in configuration

Fields declared in YAML, under config/modules/{module}/fields/{alias}/, are imported into the definitions table by an optional cache warmer: it runs with cache:warmup and cache:clear, after Doctrine's own warmer, and is skipped by --no-optional-warmers and by a warm-up with no database. Rows created that way carry a system marker, and the YAML is their source of truth: each warm-up re-applies it. Rows created through the API carry no marker and are never touched.

The warm-up never deletes. coolms:field:prune-undeclared removes a marked row whose field its alias's YAML no longer declares; it is a dry run unless given --execute, and under --no-interaction it also needs --force. It skips an alias whose YAML is gone entirely, so those rows stay until something else removes them -- the API's delete, for example.

Where an override is written

FieldOverrideStorageRouter decides, per write: in the dev environment, for an entity registered by class or alias, a YAML file, so the change can be committed with the code; in every other case -- any other environment, or a type that exists only at runtime -- the database.

Requires

PHP 8.5, api-platform/core, coolms/core, coolms/core-application, coolms/core-bundle, coolms/entity, coolms/entity-bundle, coolms/field, coolms/field-doctrine, psr/log, and the Symfony config, console, dependency-injection, form, http-foundation, http-kernel, security-bundle, serializer, validator and yaml components. DoctrineBundle with a central entity manager, as above.

Contributing

See the CoolMS organization's contributing guide.

License

MIT. See LICENSE.