nowo-tech / seed-kit-bundle
Seed data for Symfony: one provider per kind of data, export (empty template or current rows) and import of YAML / JSON / JSON Lines documents validated by a JSON Schema, a dry-run diff with a plan hash, and an idempotent batched apply through the host's own handlers with leases, access checks and a
Package info
github.com/nowo-tech/SeedKitBundle
Type:symfony-bundle
pkg:composer/nowo-tech/seed-kit-bundle
Fund package maintenance!
Requires
- php: >=8.2 <8.6
- ext-json: *
- ext-mbstring: *
- doctrine/dbal: ^3.8.2 || ^4.0
- doctrine/doctrine-bundle: ^2.8 || ^3.0
- doctrine/orm: ^3.7
- doctrine/persistence: ^3.4 || ^4.0
- nowo-tech/transaction-contract: ^1.1
- nowo-tech/transaction-doctrine: ^1.10.1
- opis/json-schema: ^2.6
- psr/clock: ^1.0
- psr/container: ^1.1 || ^2.0
- psr/event-dispatcher: ^1.0
- psr/log: ^2.0 || ^3.0
- symfony/clock: ^7.4 || ^8.0
- symfony/config: ^7.4 || ^8.0
- symfony/console: ^7.4 || ^8.0
- symfony/dependency-injection: ^7.4 || ^8.0
- symfony/event-dispatcher: ^7.4 || ^8.0
- symfony/framework-bundle: ^7.4 || ^8.0
- symfony/http-kernel: ^7.4 || ^8.0
- symfony/uid: ^7.4 || ^8.0
- symfony/yaml: ^7.4.12 || ^8.0.12
Requires (Dev)
- deptrac/deptrac: ^4.7.2
- friendsofphp/php-cs-fixer: ^3.95
- igor-php/igor-php: ^0.11
- nowo-tech/audit-kit-bundle: ^2.1
- nowo-tech/form-kit-bundle: ^2.25.1
- nowo-tech/phpstan-frankenphp: ^1.4
- nowo-tech/ui-kit-bundle: ^2.74.1
- nowo-tech/vault-bundle: ^2.4
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.3
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-symfony: ^2.0
- phpunit/phpunit: ^11.5
- rector/rector: ^2.8
- symfony/browser-kit: ^7.4 || ^8.0
- symfony/css-selector: ^7.4 || ^8.0
- symfony/dom-crawler: ^7.4 || ^8.0
- symfony/form: ^7.4 || ^8.0
- symfony/messenger: ^7.4 || ^8.0
- symfony/phpunit-bridge: ^7.4 || ^8.0
- symfony/scheduler: ^7.4 || ^8.0
- symfony/security-bundle: ^7.4 || ^8.0
- symfony/security-csrf: ^7.4 || ^8.0
- symfony/translation: ^7.4 || ^8.0
- symfony/twig-bundle: ^7.4 || ^8.0
- symfony/validator: ^7.4 || ^8.0
- twbs/bootstrap-icons: ^1.13.2
Suggests
- nowo-tech/audit-kit-bundle: Audit sink bridge (audit.auditkit): applies, prunes and sensitive exports in the action log
- nowo-tech/form-kit-bundle: Required by the opt-in UI (ui.enabled): the upload / apply forms (^2.25.1)
- nowo-tech/ui-kit-bundle: Required by the opt-in UI (ui.enabled): page scaffolds, remote upload dialog, confirm dialogs (^2.74.1)
- nowo-tech/vault-bundle: Secret-reference bridge (secrets.vault_bridge): vault:<item-uuid> checked against the target scope and the actor
- phpunit/phpunit: Nowo\SeedKitBundle\Testing\SeedProviderContractTestCase for your providers' tests
- symfony/form: Required by the opt-in UI (ui.enabled), with symfony/validator and symfony/twig-bundle
- symfony/messenger: Asynchronous apply of large UI runs (messenger.enabled): route Nowo\SeedKitBundle\Bridge\Messenger\ApplySeedRun to an async transport
- symfony/scheduler: Scheduled expiry of stored run documents and purge of the run history (scheduler.enabled)
- symfony/security-bundle: SEED_EXPORT / SEED_APPLY / SEED_PRUNE voter, role-based access checker and the user-identifier actor resolver (required by ui.enabled)
- symfony/translation: Translated console messages and row errors (domain NowoSeedKitBundle, 10 locales)
Provides
None
Conflicts
None
Replaces
None
README
⭐ Found this useful? Install it from Packagist and give it a star on GitHub: it helps us maintain and improve the project.
Seed data for Symfony, one provider per kind of data. Export an empty commented template or the current rows of a provider as YAML, JSON or JSON Lines; edit the file by hand or with an AI that reads the published JSON Schema; dry-run it as a diff with a plan hash; apply it in idempotent batches through your application's own handlers, under a lease, with access checks and an audit entry. Applying the same file twice changes nothing.
Standard Symfony by default, DDD / hexagonal opt-in: a standard host extends AbstractSeedProvider and calls its
services; a DDD host implements SeedProviderInterface in its infrastructure layer and calls its command handlers.
The public API is interfaces and value objects with no Symfony, Doctrine or HTTP types; the bundle's two tables are
mapped read-only and written through DBAL, so the bundle never flushes, clears or resets an entity manager.
📋 Compatible with Symfony 7.4, 8.0 and 8.1 · PHP 8.2+ (Symfony 8.x requires PHP 8.4+)
This bundle is FrankenPHP worker mode friendly.
Features
-
Providers: one tagged service per kind of data (
#[AsSeedProvider(name: 'crm.contacts')]or the tagnowo_seed_kit.provider), keyed by natural keys (never database ids), with dependencies applied in order (companies before contacts; unknown dependencies and cycles fail the container build). -
Documents: YAML (default, multi-document with
---), JSON (one object or{"documents": [...]}) and JSON Lines (streamed, for large files); an empty template with field comments and examples, or the current rows, round-trip stable (FORMAT.md). -
JSON Schema per provider (draft 2020-12, local
$refonly,x-seed-*keywords for keys, secrets, personal data, references and read-only fields), published for editors and AI tools, linted oncache:warmupand by a command. -
Dry run: the plan per row (create / update / unchanged / delete, changed fields) and a plan hash (
sk1:…, PLAN-HASH.md); every check that can fail runs before the first write. -
Apply: re-plans and refuses a stale plan; batches of
apply.batch_sizerows, one transaction each, under a lease per (provider, scope); each batch is re-planned with the provider's write lock and must match its reviewed digest; progress is committed with the batch; re-applying a partially applied file converges (CONCURRENCY.md). -
Prune (delete the rows the file omits) is opt-in per call, needs its own permission (
SEED_PRUNE, nobody by default) and is guarded against mass and empty prunes. -
Secrets never leave in clear: secret fields export as
vault:<ref>of the scope or are omitted; imports accept only references that a validator port (optional VaultBundle bridge) confirms; plaintext is refused without being echoed. -
Hardened reader: size, item, depth, string, property, line and node caps; YAML without tags, anchors, aliases, merge keys or directives; duplicate keys refused; console paths confined to allowed directories.
-
Access:
SEED_EXPORT/SEED_APPLY/SEED_PRUNEvoter, role-based checker (security.*), anaccess_checkerport and thenowo_seed_kit.access_checkevent; scopes (platform,organization,projector any host kind) resolved by a host port; deny by default. -
Audit: every apply and prune that passed the access check (every outcome) and every current export of a provider with personal-data or secret fields, through a PSR-3 sink or the AuditKit bridge; values are never logged.
-
Console:
nowo:seed-kit:{list,schema,export,diff,apply,runs:list,runs:purge,actor:forget,lint}withseed:*aliases;--actor=systemfor fresh installs (console only). -
Contract test kit:
Nowo\SeedKitBundle\Testing\SeedProviderContractTestCaseruns the round-trip, idempotency, stable-export, no-secret, no-escalation and row-visibility checks on your providers. -
FrankenPHP worker mode, kernel kept alive and not reset (kernel reset false): services hold configuration only, the one memo is bounded and resettable, and a 1 000-request worker test runs in CI (FRANKENPHP-WORKER-AUDIT.md).
-
10 locales (en, es, it, fr, pt, de, nl, ca, eu, gl), translation domain
NowoSeedKitBundle. -
Import / export pages (0.2, opt-in): one page per scope kind at a prefix you choose, on UiKit scaffolds and FormKit forms, wrapped in your layout (
ui.layout): downloads, an upload dialog loaded when it opens, the diff, apply / discard, history and progress (TEMPLATES.md). -
Asynchronous apply (0.2, opt-in): large UI applies are queued as
ApplySeedRunon your Messenger transport and applied once, as the run's actor, even on redelivery; a Scheduler bridge expires stored documents and purges the history.
| Import / export | Upload dialog | Diff before apply |
|---|---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Installation
composer require nowo-tech/seed-kit-bundle
With Symfony Flex the recipe registers the bundle and writes config/packages/nowo_seed_kit.yaml. Create the two
bundle tables with your migrations or the Doctrine schema tool (docs/INSTALLATION.md), write a
provider, then:
bin/console nowo:seed-kit:list bin/console nowo:seed-kit:export catalog.categories --empty --actor=admin --output=config/seeds/categories.yaml bin/console nowo:seed-kit:diff config/seeds/categories.yaml --actor=admin bin/console nowo:seed-kit:apply config/seeds/categories.yaml --yes --actor=admin
Requirements
- PHP >= 8.2, < 8.6 with
ext-jsonandext-mbstring(ext-intlfor thenfckey normaliser) - Symfony 7.4, 8.0 or 8.1; Doctrine DBAL 3.8+ / 4, ORM 3.7+, DoctrineBundle 2.8+ / 3
opis/json-schema^2.6,nowo-tech/transaction-contract^1.1,nowo-tech/transaction-doctrine^1.10.1- MySQL 8.4, MariaDB 11.4, PostgreSQL 16+ or SQLite
- Optional:
symfony/security-bundle(voter, role checker, user actor),symfony/translation(translated console messages),phpunit/phpunit(contract test kit),nowo-tech/audit-kit-bundle(audit bridge),nowo-tech/vault-bundle(secret-reference bridge)
Configuration
Zero configuration works for a standard host with one platform scope. A multi-tenant host declares its scope kinds,
a scope resolver and its access mapping:
nowo_seed_kit: scope_kinds: platform: { requires_id: false } organization: { requires_id: true } scope_resolver: App\Seed\TenantScopeResolver security: prune_roles: [ROLE_ADMIN] providers: crm.contacts: { export_roles: [ROLE_CRM_ADMIN], apply_roles: [ROLE_CRM_ADMIN] }
Every key, its default and its range: docs/CONFIGURATION.md.
Usage
Standard Symfony host: extend AbstractSeedProvider, describe one item with a JSON Schema, read the current rows
by natural key and write through your own services:
#[AsSeedProvider(name: 'catalog.categories')] final class CategoryProvider extends AbstractSeedProvider { public function name(): ProviderName { return new ProviderName('catalog.categories'); } public function version(): int { return 1; } public function scopes(): array { return [new ScopeKind(ScopeKind::PLATFORM)]; } public function schema(): SeedSchema { /* item schema with 'x-seed-key' => ['slug'] */ } public function exportCurrent(SeedContext $context): iterable { /* one SeedItem per row, by slug */ } public function applyBatch(SeedContext $context, AppliedBatch $batch): BatchResult { /* your services */ } protected function currentRows(SeedContext $context, array $keys, PlanOptions $options): array { /* by key */ } }
DDD / hexagonal host: implement SeedProviderInterface in the infrastructure layer, plan with your read model,
apply through your command handlers, and plug your own scope resolver, actor resolver and access checker.
Both paths in full, the schema keywords, secrets, prune, every console command with its exit codes, the AI editing workflow, the access mapping and the contract test kit: docs/USAGE.md.
Demo
demo/symfony8 (Symfony 8.1, PHP 8.5, http://localhost:8271): FrankenPHP worker mode, MySQL 8.4, UiKit layout, two
providers (catalog.categories and catalog.products, with a reference and a float price), seed files in
config/seeds, a home page with row counts and the last runs, and downloads of the template, the current export and
the schema for admin (may export) and viewer (denied), password demo. make -C demo up-symfony8, then
make -C demo/symfony8 seed, make test-e2e and make demo-screenshots. See
docs/DEMO-FRANKENPHP.md.
Documentation
- Installation
- Configuration
- Usage
- Contributing
- Code of Conduct
- Changelog
- Upgrading
- Release
- Security
- Engram
- Spec-driven development
- GitHub Spec Kit
- Roadmap
Additional documentation
- Document format
- Plan hash and batch digests
- Architecture
- Concurrency
- FrankenPHP worker audit
- Privacy
- Templates and pages
- Contract
- Demo with FrankenPHP
- GitHub Actions CI
- PSR evaluation
Tests and coverage
- Unit, integration and database suites (PHPUnit): value objects and canonical JSON, the hostile reader corpus, the planner, applier and exporter, the contract test kit, the console commands, the access matrix, the container wiring of a standard and a DDD host, and a worker test (one kernel, 1 000 mixed requests, two actors, flat memory). The database suite runs on SQLite and, in CI, on MySQL 8.4, MariaDB 11.4 and PostgreSQL, including the two-connection lease and lock tests.
- Coverage:
- PHP: 100%
- TS/JS: N/A
- Python: N/A
License
MIT. See LICENSE.
Author
Created by Héctor Franco Aceituno at Nowo.tech.







