Part of the Jardis Ecosystem — A modular DDD framework for PHP
DDD Foundation for PHP. Domain orchestration with BoundedContext, Request/Response handling and zero-config infrastructure services for Database, Cache, Logger, and Messaging.
- Domain Context — Base Domain class with automatic path detection and kernel bootstrapping
- Bounded Context — Request/Response handling with Factory integration and version-based class resolution
- Multi-Layer Caching — Memory → APCu → Redis → Database cascade
- Connection Pool — Connection pooling with read/write splitting via
ConnectionPoolInterface - Smart Logging — Conditional routing, sampling, fingers-crossed buffering, 20 handlers (File, Slack, Teams, Loki, Kafka, RabbitMQ, Email, Webhook, etc.)
- Flexible Messaging — Redis Streams, Kafka, RabbitMQ with priority-based selection
- SharedRuntime — Organization-wide infrastructure configuration as sibling directory, auto-detected
- Cross-Domain Connection Sharing — Multiple kernels automatically share connections
- Dynamic Class Versioning — Load different implementations by version at runtime via SubDirectory and Proxy loaders
composer require jardiscore/foundationuse JardisCore\Foundation\Domain;
use JardisCore\Foundation\Context\BoundedContext;
use JardisCore\Foundation\Context\Request;
use JardisPort\Foundation\ResponseInterface;
// Standard: ClassVersion with SubDirectory and Proxy loaders is active by default.
class MyDomain extends Domain
{
public function myContext(Request $request): ResponseInterface
{
$context = new BoundedContext($this->getKernel(), $request);
return $context->handle(MyBoundedContext::class);
}
}
// Custom: Provide own ClassVersionConfig
class EcommerceDomain extends Domain
{
protected function getClassVersion(
?ClassVersionConfigInterface $config = null,
): ?ClassVersionInterface {
$config = new ClassVersionConfig(
version: ['v1' => ['legacy'], 'v2' => ['current']],
fallbacks: ['v2' => ['v1']]
);
return parent::getClassVersion($config);
}
}Infrastructure services via DomainKernel:
use JardisCore\Foundation\Adapter\DomainKernel;
$kernel = new DomainKernel($appRoot, $domainRoot);
$pool = $kernel->getConnectionPool(); // ConnectionPoolInterface
$cache = $kernel->getCache(); // CacheInterface (PSR-16)
$logger = $kernel->getLogger(); // LoggerInterface (PSR-3)
$messaging = $kernel->getMessage(); // MessagingServiceInterface
$factory = $kernel->getFactory(); // FactoryInterfaceDomain-specific kernels via overridable createKernel():
class EcommerceDomain extends Domain
{
protected function createKernel(
string $appRoot,
string $domainRoot,
?ClassVersionInterface $classVersion,
ResourceRegistryInterface $resources,
?string $sharedRuntimeRoot = null
): DomainKernelInterface {
return new EcommerceKernel($appRoot, $domainRoot, $classVersion, $resources, $sharedRuntimeRoot);
}
}Organization-wide infrastructure settings can be shared across domains via a SharedRuntime/ directory placed as a sibling of the domain root:
project/
├── SharedRuntime/ # Shared .env for all domains
│ └── .env
├── EcommerceDomain/
│ └── .env # Domain-specific overrides
└── UserDomain/
└── .env
The environment cascade loads in this order (later values override earlier):
AppRoot (public) → Foundation (private) → SharedRuntime (private) → Domain (private)
Domain auto-detects SharedRuntime/ as sibling of domainRoot. No configuration needed.
Full documentation, examples and API reference:
→ jardis.io/docs/core/foundation
This package is part of the Jardis Ecosystem — a collection of modular, high-quality PHP packages designed for Domain-Driven Design.
| Category | Packages |
|---|---|
| Core | Foundation |
| Adapter | Cache, Logger, Messaging, DbConnection |
| Support | DotEnv, DbQuery, Validation, Factory, ClassVersion, Workflow, Data, Repository |
| Tools | DomainBuilder, DbSchema |
This package is licensed under the PolyForm Noncommercial License 1.0.0.
For commercial use, see COMMERCIAL.md.