jardiscore / foundation
Jardis DDD Platform — zero-config infrastructure with DB, Cache, Logger, Messaging
Requires
- php: >=8.2
- ext-json: *
- ext-pdo: *
- jardisadapter/cache: ^1.0
- jardisadapter/dbconnection: ^1.0
- jardisadapter/logger: ^1.0
- jardisadapter/messaging: ^1.0
- jardiscore/kernel: ^1.0
- jardissupport/classversion: ^1.0
- jardissupport/contract: ^1.0
- jardissupport/data: ^1.0
- jardissupport/dotenv: ^1.0
- jardissupport/factory: ^1.0
- jardissupport/repository: ^1.0
Requires (Dev)
- ext-amqp: *
- ext-apcu: *
- ext-rdkafka: *
- ext-redis: *
- phpstan/phpstan: ^2.0.4
- phpunit/phpunit: ^11.0
- squizlabs/php_codesniffer: ^3.11.2
This package is auto-updated.
Last update: 2026-03-31 08:07:59 UTC
README
Part of the Jardis Business Platform — Enterprise-grade PHP components for Domain-Driven Design
Jardis DDD Platform — extends jardiscore/kernel with zero-config infrastructure. Bootstraps a fully assembled, immutable DomainKernel from .env configuration — or reuses your existing connections. No duplicate connections, no wasted resources.
Already have a PDO or Redis? Inject it. Foundation only creates what's missing. Multiple domains? Share connections across them — no static state, no singletons.
Features
- Zero-config or bring your own — Bootstraps all services from ENV, but accepts existing PDO, Redis, Kafka, RabbitMQ connections. Injected connections take priority — nothing is created twice
- DomainKernelBuilder — Assembles an immutable
DomainKernelfrom ENV cascade with all infrastructure services - DomainKernel — Extends
jardiscore/kernelDomainKernel with ConnectionPool support for read/write splitting - Domain base class — Auto-detects paths, bootstraps via Builder, supports SharedRuntime
- ConnectionProvider — Typed connection registry with lazy factories from ENV and external injection
- Cross-domain connection sharing —
shareInto()/mergeFrom()reuses PDO and Redis across domains without static state - Multi-layer caching — Memory -> APCu -> Redis -> PDO, configurable per environment (PSR-16)
- Connection pool — Read/write splitting with dedicated writer + reader PDOs
- Smart Logging — 17 handler types with conditional activation (PSR-3)
- Flexible Messaging — Redis Streams, RabbitMQ, Kafka simultaneously from ENV
- SharedRuntime — Organization-wide infrastructure config, auto-detected
Kernel vs. Foundation
Foundation builds on top of jardiscore/kernel — the portable DDD core with zero infrastructure dependencies.
jardiscore/kernel |
jardiscore/foundation |
|
|---|---|---|
| Purpose | DDD Core — portable, no infrastructure | DDD Platform — zero-config infrastructure |
| Dependencies | Only PSR interfaces + PDO | Kernel + all Jardis adapters (Cache, DB, Logger, Messaging) |
| DomainKernel | Simple, constructor injection | Extends Kernel, adds ENV cascade + ConnectionPool |
| Domain | new MyDomain($kernel) — kernel required |
new MyDomain() — lazy bootstrap from ENV |
| Use when | Own infrastructure, no Jardis ecosystem | Jardis projects, generated DDD code |
Use Kernel if you want the DDD building blocks (BoundedContext, ContextResponse, DomainResponse) without Jardis infrastructure. Use Foundation for the full platform experience with auto-configured services.
Installation
composer require jardiscore/foundation
Quick Start
use JardisCore\Foundation\Domain; class EcommerceDomain extends Domain { public function placeOrder(array $orderData): DomainResponseInterface { $context = $this->handle(PlaceOrder::class); return $context($orderData); } } // Zero-config: paths auto-detected, ENV loaded, kernel bootstrapped $domain = new EcommerceDomain(); $response = $domain->placeOrder($data);
Manual Bootstrap
use JardisCore\Foundation\DomainKernelBuilder; $kernel = (new DomainKernelBuilder())( appRoot: '/var/www', domainRoot: '/var/www/src/Ecommerce', ); // Immutable kernel with all services assembled from ENV $kernel->cache(); // ?CacheInterface (PSR-16) $kernel->logger(); // ?LoggerInterface (PSR-3) $kernel->dbWriter(); // ?PDO $kernel->dbReader(); // ?PDO (falls back to writer) $kernel->container(); // ContainerInterface (PSR-11, has ConnectionPool + Messaging)
ENV Cascade
AppRoot/.env <- public, loaded into $_ENV
Foundation/.env <- Foundation defaults (private)
SharedRuntime/.env <- organization-wide infrastructure (private)
DomainRoot/.env <- domain-specific, highest priority (private)
Bring Your Own Connections
Foundation bootstraps connections from ENV by default — but you can inject existing connections from your project. External connections take priority over ENV, so nothing is created twice:
use JardisCore\Foundation\Connection\ConnectionProvider; use JardisCore\Foundation\DomainKernelBuilder; $connections = new ConnectionProvider(); $connections->setWriter($existingPdo); // reuse your existing PDO $connections->setCacheRedis($existingRedis); // reuse your existing Redis // Builder uses injected connections, only creates what's missing from ENV $kernel = (new DomainKernelBuilder())( appRoot: '/var/www', domainRoot: '/var/www/src/Ecommerce', connections: $connections, );
For multi-domain setups, SharedConnections shares connections across domains without static state:
use JardisCore\Foundation\Connection\SharedConnections; $shared = new SharedConnections(); // Domain A shares its connections after bootstrap $domainA->getConnectionProvider()->shareInto($shared); // Domain B merges them in — local connections win, shared fill the gaps $connectionsB = new ConnectionProvider(); $connectionsB->mergeFrom($shared);
Architecture
Domain (path detection + bootstrap)
└── DomainKernelBuilder.__invoke() (ENV cascade + Handler assembly)
├── ConnectionProvider (typed connection registry)
│ └── Connection/Handler/ (PdoHandler, RedisHandler, KafkaHandler, AmqpHandler)
├── CacheHandler -> CacheInterface (Memory|APCu|Redis|DB)
├── DatabaseHandler -> ConnectionPoolInterface (Round-Robin)
├── LoggerHandler -> LoggerInterface (17 handler types)
├── MessagingHandler -> MessagingServiceInterface (Redis|Kafka|AMQP|InMemory)
└── Factory (PSR-11 Container with all instances)
└── DomainKernel (immutable, all services injected)
Package Layering
| Package | Role |
|---|---|
jardisport/kernel |
Interfaces (DomainKernelInterface, BoundedContextInterface, etc.) |
jardiscore/kernel |
DDD core (Domain, DomainKernel, BoundedContext, ContextResponse, DomainResponse) |
jardiscore/foundation |
Platform (DomainKernelBuilder, ConnectionProvider, Service Handlers) |
Dependencies
| Package | Role |
|---|---|
jardiscore/kernel |
DDD core (BoundedContext, ContextResponse, DomainResponse) |
jardisport/kernel |
DomainKernelInterface |
jardissupport/factory |
PSR-11 Container |
jardissupport/classversion |
Versioned class resolution |
jardissupport/dotenv |
Environment variable loading |
jardisadapter/cache |
Cache adapters |
jardisadapter/dbconnection |
Database connection pool |
jardisadapter/logger |
Logger handlers |
jardisadapter/messaging |
Messaging transports |
License
Licensed under the PolyForm Shield License 1.0.0. Free for all use except building competing frameworks or developer tooling.