Skip to content

jardisPort/connection

Repository files navigation

Jardis Connection Port

Build Status License: PolyForm Shield PHP Version PHPStan Level PSR-12

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.


Interfaces

ConnectionInterface

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.

Installation

composer require jardisport/connection

Usage

use 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
    }
}

Implemented by

Documentation

Full documentation, guides, and API reference:

jardis.io/docs/port/connection

License

This package is licensed under the PolyForm Shield License 1.0.0. Free for all use except building competing frameworks or developer tooling.


Jardis · Documentation · Headgent

About

Base connection interface for all Jardis adapters

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors