Part of the Jardis Business Platform — Enterprise-grade PHP components for Domain-Driven Design
The foundational connection contract for all Jardis adapters. Every adapter — database, cache, messaging — builds on this interface for consistent lifecycle management across the platform. Type-hint against ConnectionInterface to write adapter-agnostic code that works with any underlying transport.
JardisPort\Connection\ConnectionInterface
The minimal lifecycle contract every connection must implement. Idempotent by design — calling connect() or disconnect() multiple times is always safe.
| Method | Signature | Description |
|---|---|---|
connect |
connect(): void |
Establish the connection. No-op if already connected. Throws \RuntimeException on failure. |
disconnect |
disconnect(): void |
Close the connection. No-op if already disconnected. |
isConnected |
isConnected(): bool |
Check whether the connection is currently active. |
composer require jardisport/connectionuse JardisPort\Connection\ConnectionInterface;
// Type-hint against the interface — not against any specific adapter
class MyService
{
public function __construct(
private readonly ConnectionInterface $connection,
) {}
public function doWork(): void
{
if (!$this->connection->isConnected()) {
$this->connection->connect();
}
// ... use the connection
}
}- jardisadapter/dbconnection — PDO-based database connections with read/write splitting and connection pooling
- jardisadapter/cache — Redis and other cache backend connections
- jardisadapter/messaging — Redis, Kafka, and RabbitMQ transport connections
Full documentation, guides, and API reference:
jardis.io/docs/port/connection
This package is licensed under the PolyForm Shield License 1.0.0. Free for all use except building competing frameworks or developer tooling.