adachsoft / dynamic-tables-form-json
File-based JSON persistence for dynamic table form definitions and display configurations
Package info
gitlab.com/a.adach/dynamic-tables-form-json
pkg:composer/adachsoft/dynamic-tables-form-json
Requires
- php: >=8.3
- adachsoft/dynamic-tables-form-contract: ^0.1.1
- adachsoft/dynamic-tables-form-core: ^0.1.0
Requires (Dev)
- adachsoft/php-code-style: ^0.7.4
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^13.0
- rector/rector: ^2.9
- symplify/phpstan-rules: ^14.19
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
File-based JSON persistence for the dynamic-tables form-schema system.
This package provides concrete repository implementations of
FormDefinitionRepositoryInterface and DisplayConfigRepositoryInterface
from adachsoft/dynamic-tables-form-contract, backed by local JSON files.
It is framework-agnostic — no Symfony or other framework dependencies.
Responsibility is limited to DTO ↔ JSON serialization and filesystem I/O.
Domain exceptions (FormDefinitionNotFoundException, DuplicateFormDefinitionException,
DisplayConfigNotFoundException) come from adachsoft/dynamic-tables-form-core.
I/O and JSON parse errors are wrapped in the local FormJsonStorageException.
Namespace: AdachSoft\DynamicTablesFormJson
Requirements
- PHP
>= 8.3 adachsoft/dynamic-tables-form-contract^0.1.1adachsoft/dynamic-tables-form-core^0.1.0
Installation
Install the package and its dependencies with Composer:
composer require adachsoft/dynamic-tables-form-json
Composer's PSR-4 autoloader maps the library namespace to src/.
Package structure
src/
├── Exception/ Storage-specific exceptions
├── Repository/ File-based repository implementations
└── Serializer/ DTO ↔ JSON serializers
Components
| Class | Responsibility |
|---|---|
Repository\FileFormDefinitionRepository | CRUD for form definitions as {storageDir}/{name}.json |
Repository\FileDisplayConfigRepository | Upsert/read/delete display config as {storageDir}/{tableId}.json |
Serializer\FormDefinitionSerializer | Serialize/deserialize FormDefinitionResponseDto |
Serializer\DisplayConfigSerializer | Serialize/deserialize DisplayConfigResponseDto |
Exception\FormJsonStorageException | Wrapper for I/O and JSON errors |
Usage
Form definitions
use AdachSoft\DynamicTablesFormJson\Repository\FileFormDefinitionRepository;
use AdachSoft\DynamicTablesFormJson\Serializer\FormDefinitionSerializer;
use AdachSoft\DynamicTablesFormContract\Vo\FormNameVo;
$repository = new FileFormDefinitionRepository(
storageDir: '/var/data/form-definitions',
formDefinitionSerializer: new FormDefinitionSerializer(),
);
// Create
$repository->create($formDefinitionResponseDto);
// Read
$dto = $repository->get(new FormNameVo('animal_form'));
$all = $repository->getAll();
$byTable = $repository->findForTable('animals'); // ?FormDefinitionResponseDto
// Update / delete
$repository->update($formDefinitionResponseDto);
$repository->delete(new FormNameVo('animal_form'));
Display config
use AdachSoft\DynamicTablesFormJson\Repository\FileDisplayConfigRepository;
use AdachSoft\DynamicTablesFormJson\Serializer\DisplayConfigSerializer;
$repository = new FileDisplayConfigRepository(
storageDir: '/var/data/display-configs',
displayConfigSerializer: new DisplayConfigSerializer(),
);
// Upsert (create or overwrite)
$repository->save($displayConfigResponseDto);
// Read
$dto = $repository->get('animals');
$maybe = $repository->find('animals'); // null when missing
// Delete
$repository->delete('animals');
JSON schema
Both serializers write _schemaVersion: 1 for future migrations.
Form definition file ({name}.json)
{
"name": "animal_form",
"tableId": "animals",
"theme": "default",
"fieldOverrides": [
{
"fieldName": "name",
"label": "Name",
"widget": "text",
"widgetParams": null,
"hidden": false,
"order": 1,
"readOnly": false
}
],
"sections": [
{
"name": "main",
"label": "Main",
"fieldNames": ["name"]
}
],
"_schemaVersion": 1
}
Display config file ({tableId}.json)
{
"tableId": "animals",
"labelTemplate": "{name}",
"searchableFields": ["name", "code"],
"_schemaVersion": 1
}
Exceptions
| Exception | Source | When |
|---|---|---|
FormJsonStorageException | this package | I/O failure, invalid JSON, missing required keys |
FormDefinitionNotFoundException | form-core | get / update / delete on missing form |
DuplicateFormDefinitionException | form-core | create when file already exists |
DisplayConfigNotFoundException | form-core | get / delete on missing display config |
Design rules
- Infrastructure only — no domain rules beyond repository contracts.
- Single storage exception — all I/O and parse failures go through
FormJsonStorageException. - Domain exceptions from core — not-found / duplicate semantics stay in
dynamic-tables-form-core. - Framework-agnostic — plain PHP filesystem APIs; no framework types.
- Auto-create storage directory —
create/savecreate$storageDirwhen missing.
Development
Run the test suite and quality tools from the package root:
vendor/bin/phpunit --configuration phpunit.xml
vendor/bin/phpstan analyse src tests
vendor/bin/rector process src tests
vendor/bin/php-cs-fixer fix src tests
License
MIT
Author
Arkadiusz Adach