adachsoft / dynamic-tables-form-contract
Framework-agnostic contracts and data types for dynamic table form schemas
Package info
gitlab.com/a.adach/dynamic-tables-form-contract
pkg:composer/adachsoft/dynamic-tables-form-contract
Requires
- php: >=8.3
- adachsoft/collection: ^3.0
- adachsoft/dynamic-table-contract: ^1.0
Requires (Dev)
- adachsoft/php-code-style: ^0.7.4
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^13
- rector/rector: ^2.9
- symplify/phpstan-rules: ^14.19
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Framework-agnostic public contract for the dynamic-tables form-schema system.
This package defines the stable API surface used by all other form-related packages: interfaces, readonly DTOs, value objects, enums, typed collections, and exception interfaces. It contains no business implementation.
Namespace: AdachSoft\DynamicTablesFormContract
Requirements
- PHP
>= 8.3 adachsoft/collection^3.0adachsoft/dynamic-table-contract^1.0
Installation
When used from the monorepo root (recommended during development):
composer install
The root composer.json maps:
AdachSoft\DynamicTablesFormContract\ → packages/dynamic-tables-form-contract/src/
AdachSoft\DynamicTablesFormContract\Tests\ → packages/dynamic-tables-form-contract/tests/
As a standalone library (when published):
composer require adachsoft/dynamic-tables-form-contract
Package structure
src/
├── Collection/ Typed immutable collections (adachsoft/collection)
├── Dto/ Input and response DTOs (readonly)
├── Enum/ WidgetEnum and related enums
├── Exception/ Exception marker interfaces (+ package-local concrete where needed)
├── Facade/ Public entry-point interfaces
├── Repository/ Persistence contracts
├── Service/ Domain service contracts
└── Vo/ Value objects (FormNameVo, LabelTemplateVo)
Main facades
| Interface | Responsibility |
|---|---|
Facade\DynamicFormFacadeInterface | Form definition CRUD and schema generation |
Facade\LookupFacadeInterface | Lookup endpoint for relation fields |
Facade\DisplayConfigFacadeInterface | Table display config (label template + searchable fields) |
DynamicFormFacadeInterface
getAllDefinitions()/getDefinition(string $formName)createDefinition(CreateFormDefinitionDto)/updateDefinition(...)/deleteDefinition(...)getSchemaForTable(string $tableId)getSchemaForView(string $viewName)getSchemaForForm(string $formName)
LookupFacadeInterface
lookup(string $tableId, LookupQueryDto $query): LookupResponseDto
DisplayConfigFacadeInterface
find/get/save/deletefor per-table display configuration
Usage
Depend on the facade interfaces in your application layer and provide their implementations in the package or application that owns the behavior. This library contains contracts and data types only; it does not register services or provide persistence. See the usage examples for value-object validation and facade integration.
Integration
Depend on the facade interfaces in your application layer and provide their implementations in the package or application that owns the behavior. This library contains contracts and data types only; it does not register services or provide persistence.
use AdachSoft\DynamicTablesFormContract\Dto\FormSchemaResponseDto;
use AdachSoft\DynamicTablesFormContract\Facade\DynamicFormFacadeInterface;
use AdachSoft\DynamicTablesFormContract\Vo\FormNameVo;
function loadFormSchema(DynamicFormFacadeInterface $forms, string $formName): FormSchemaResponseDto
{
return $forms->getSchemaForForm((new FormNameVo($formName))->value);
}
See the usage examples for value-object validation and facade integration.
Value objects
FormNameVo
Form definition name in snake_case.
- Pattern:
^[a-z][a-z0-9_]*$ - Throws
\InvalidArgumentExceptionon empty or invalid input
LabelTemplateVo
Label template with {placeholder} syntax (e.g. {name} ({city})).
- Validates non-empty value and balanced
{...}placeholders - Throws
InvalidLabelTemplateExceptionInterfaceon invalid input placeholders(): string[]returns unique placeholder names in order of first occurrence
Collections
All collections extend AdachSoft\Collection\AbstractImmutableCollection and reject invalid item types.
| Collection | Item type | Extra API |
|---|---|---|
FieldSchemaCollection | FieldSchemaResponseDto | findByName(string): ?FieldSchemaResponseDto |
FieldOverrideCollection | FieldOverrideDto | findByFieldName(string): ?FieldOverrideDto |
SectionCollection | SectionDto | — |
LookupItemCollection | LookupItemDto | — |
SearchableFieldCollection | string | — |
Widgets
Enum\WidgetEnum (string-backed):
text, textarea, number, checkbox, checkbox-group, radio, select, autocomplete, date, datetime, json, money
Exception interfaces
Form-related:
FormExceptionInterfaceFormDefinitionNotFoundExceptionInterfaceDuplicateFormDefinitionExceptionInterfaceInvalidFormDefinitionExceptionInterfaceFormSchemaUnavailableForUnionViewExceptionInterfaceTableNotConfiguredForLookupExceptionInterfaceInvalidLabelTemplateExceptionInterface
Display-config-related:
DisplayConfigExceptionInterfaceDisplayConfigNotFoundExceptionInterfaceInvalidDisplayConfigExceptionInterface
Concrete exception classes that implement these interfaces live in implementation packages (e.g. form-core), except for package-local helpers required by VO construction.
Design rules
- Contract only — no application or infrastructure logic in this package.
- DTOs are readonly — plain data carriers for input/output boundaries.
- Single enforcement point — VO validation happens in constructors; collections enforce item types via
isValidItem(). - Framework-agnostic — no Symfony/Laravel/Doctrine types in the public API.
Development
Run package tests from the monorepo root:
./vendor/bin/phpunit packages/dynamic-tables-form-contract/tests
Static analysis / style (from monorepo root, paths limited to this package):
./vendor/bin/phpstan analyse packages/dynamic-tables-form-contract/src packages/dynamic-tables-form-contract/tests
./vendor/bin/rector process packages/dynamic-tables-form-contract/src packages/dynamic-tables-form-contract/tests
./vendor/bin/php-cs-fixer fix packages/dynamic-tables-form-contract/src packages/dynamic-tables-form-contract/tests
License
MIT
Author
Arkadiusz Adach