PHPackages                             edgebinder/edgebinder - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. edgebinder/edgebinder

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

edgebinder/edgebinder
=====================

Lightweight, storage-agnostic relationship management for clean domain architectures

v0.9.0(9mo ago)01.6k↓50%2Apache-2.0PHPPHP ^8.3CI passing

Since Aug 1Pushed 9mo agoCompare

[ Source](https://github.com/EdgeBinder/edgebinder)[ Packagist](https://packagist.org/packages/edgebinder/edgebinder)[ Docs](https://github.com/EdgeBinder/edgebinder)[ RSS](/packages/edgebinder-edgebinder/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (16)Used By (2)

EdgeBinder
==========

[](#edgebinder)

[![Tests](https://github.com/EdgeBinder/edgebinder/actions/workflows/test.yaml/badge.svg)](https://github.com/EdgeBinder/edgebinder/actions/workflows/test.yaml)[![Lint](https://github.com/EdgeBinder/edgebinder/actions/workflows/lint.yaml/badge.svg)](https://github.com/EdgeBinder/edgebinder/actions/workflows/lint.yaml)[![codecov](https://camo.githubusercontent.com/295d4fbaa26dee4777f39f39b6cb2e3514325b8eb9099d5d22ebc6d7661a7f15/68747470733a2f2f636f6465636f762e696f2f67682f4564676542696e6465722f6564676562696e6465722f67726170682f62616467652e737667)](https://codecov.io/gh/EdgeBinder/edgebinder)[![PHP Version](https://camo.githubusercontent.com/5c8ce4571ddf4b6b8ca847e0c4c079de98fc6460eb7eae9c81ca63319c21f546/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e332d626c75652e737667)](https://php.net/)[![License](https://camo.githubusercontent.com/b29de0acdfd19013f1f02689b15c933e4a6c145be9efa718288f88ba3280b1c5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d417061636865253230322e302d626c75652e737667)](LICENSE)

Lightweight, storage-agnostic relationship management for clean domain architectures. EdgeBinder provides a simple, elegant way to manage entity relationships without the complexity of full ORMs or the limitations of basic pivot tables.

EdgeBinder follows Domain-Driven Design principles and provides a clean abstraction layer over various storage backends through pluggable adapters. Whether you need simple SQL storage, document databases, or advanced vector databases, EdgeBinder adapts to your needs.

Features
--------

[](#features)

- **Storage Agnostic**: Use any storage backend through pluggable adapters
- **Rich Metadata**: Store complex relationship data with full metadata support
- **Type Safe**: Full PHP 8.3+ type safety with comprehensive PHPStan analysis
- **Domain-Driven Design**: Clean abstraction that doesn't pollute your domain entities
- **Query Builder**: Fluent, expressive query interface for relationship discovery
- **Performance Focused**: Optimized for relationship queries and bulk operations
- **Framework Agnostic**: Works seamlessly with Laminas, Symfony, Laravel, Slim, and any PSR-11 framework
- **Extensible**: Third-party adapters work across all frameworks without modifications

Requirements
------------

[](#requirements)

- PHP 8.3 or higher
- Composer

Installation
------------

[](#installation)

```
composer require edgebinder/edgebinder
```

Quick Start
-----------

[](#quick-start)

### Basic Usage

[](#basic-usage)

```
use EdgeBinder\EdgeBinder;
use EdgeBinder\Persistence\InMemory\InMemoryAdapter;

// Option 1: Direct adapter usage (for testing/development)
$adapter = new InMemoryAdapter();
$binder = new EdgeBinder($adapter);

// Option 2: Configuration-based approach (recommended)
use EdgeBinder\Registry\AdapterRegistry;
use EdgeBinder\Persistence\InMemory\InMemoryAdapterFactory;

AdapterRegistry::register(new InMemoryAdapterFactory());
$binder = EdgeBinder::fromConfiguration(['adapter' => 'inmemory'], $container);

// Bind entities with rich metadata
$binder->bind(
    from: $user,
    to: $project,
    type: 'has_access',
    metadata: [
        'access_level' => 'write',
        'granted_by' => $adminUserId,
        'granted_at' => new DateTimeImmutable(),
        'expires_at' => new DateTimeImmutable('+1 year'),
    ]
);

// Query relationships
$projects = $binder->query()
    ->from($user)
    ->type('has_access')
    ->where('access_level', 'write')
    ->get();
```

### Using Third-Party Adapters

[](#using-third-party-adapters)

EdgeBinder supports both automatic and manual adapter registration:

EdgeBinder adapters automatically register when their packages are loaded:

```
use EdgeBinder\EdgeBinder;

// No registration needed - adapters auto-register when packages are loaded
$config = [
    'adapter' => 'redis',
    'redis_client' => 'redis.client.cache',
    'ttl' => 3600,
    'prefix' => 'edgebinder:',
];

$binder = EdgeBinder::fromConfiguration($config, $container);

// Use exactly the same API regardless of adapter
$binder->bind($user, $project, 'has_access', ['level' => 'admin']);
```

> **Note**: For creating custom adapters, see the [Extensible Adapters Guide](docs/EXTENSIBLE_ADAPTERS.md) for implementation details.

Development Setup
-----------------

[](#development-setup)

### 1. Clone and Install Dependencies

[](#1-clone-and-install-dependencies)

```
git clone https://github.com/EdgeBinder/edgebinder.git
cd edgebinder
composer install
```

### 2. Run Tests

[](#2-run-tests)

```
# Run all tests
composer test

# Run only unit tests
vendor/bin/phpunit tests/Unit

# Run only integration tests
vendor/bin/phpunit tests/Integration

# Run tests with coverage
composer test-coverage
```

### 3. Code Quality

[](#3-code-quality)

```
# Run static analysis
composer phpstan

# Check coding standards
composer cs-check

# Fix coding standards
composer cs-fix

# Check composer.json normalization
composer composer-normalize

# Fix composer.json normalization
composer composer-normalize-fix

# Security audit
composer security-audit
```

Project Structure
-----------------

[](#project-structure)

```
src/
├── EdgeBinder.php                 # Main EdgeBinder class with factory methods
├── Binding.php                    # Binding entity representation
├── Contracts/
│   ├── PersistenceAdapterInterface.php  # Adapter interface
│   ├── EdgeBinderInterface.php    # Main service interface
│   └── EntityInterface.php       # Optional entity interface
├── Query/
│   └── BindingQueryBuilder.php    # Query builder for relationships
├── Registry/                      # Extensible adapter system
│   ├── AdapterFactoryInterface.php # Factory interface for third-party adapters
│   └── AdapterRegistry.php       # Static registry for adapter discovery
├── Storage/
│   └── InMemory/
│       └── InMemoryAdapter.php    # Built-in in-memory adapter
└── Exception/
    ├── AdapterException.php       # Adapter-related exceptions
    ├── BindingNotFoundException.php
    ├── EntityExtractionException.php
    ├── InvalidMetadataException.php
    └── PersistenceException.php

docs/                              # Comprehensive documentation
├── EXTENSIBLE_ADAPTERS.md         # Third-party adapter development guide
├── FRAMEWORK_INTEGRATION.md       # Framework-specific integration examples
└── MIGRATION_GUIDE.md            # Migration guide for existing adapters

examples/                          # Reference implementations
└── RedisAdapter/                  # Complete Redis adapter example
    ├── src/
    │   ├── RedisAdapter.php
    │   └── RedisAdapterFactory.php
    └── tests/

tests/
├── Unit/                          # Unit tests (196 tests)
│   ├── Contracts/                 # Interface contract tests
│   ├── Exception/                 # Exception hierarchy tests
│   ├── Persistence/InMemory/      # InMemory adapter tests
│   ├── Query/                     # Query builder tests
│   └── Registry/                  # Registry system tests
└── Integration/                   # Integration tests (14 tests)
    └── ... (end-to-end workflow tests)

```

Contributing
------------

[](#contributing)

1. Fork the repository
2. Create a feature branch
3. Write tests for your changes
4. Ensure all tests pass: `composer test`
5. Ensure code quality: `composer phpstan && composer cs-check && composer composer-normalize && composer security-audit`
6. Submit a pull request

Testing Philosophy
------------------

[](#testing-philosophy)

This project follows Test-Driven Development (TDD) with a clear separation of test types:

### Unit Tests (`tests/Unit/`)

[](#unit-tests-testsunit)

- **196 tests** focusing on individual component behavior
- Fast, isolated tests with mocked dependencies
- Test individual methods, edge cases, and error conditions
- Organized by source code structure

### Integration Tests (`tests/Integration/`)

[](#integration-tests-testsintegration)

- **14 tests** focusing on cross-component workflows
- Test real interactions between components
- End-to-end scenarios with actual dependencies
- Framework integration and adapter lifecycle testing

### **AbstractAdapterTestSuite** (`src/Testing/`)

[](#abstractadaptertestsuite-srctesting)

- **57 comprehensive compliance tests** for all adapters
- **REQUIRED for all adapter implementations**
- Tests real EdgeBinder integration scenarios
- Covers all query patterns, metadata handling, and edge cases
- **84.71% line coverage** of reference implementation
- **Proven to catch production bugs** (found 5+ critical issues)

**Total Coverage**: 267+ tests with 97%+ line coverage

Extensible Adapter System
-------------------------

[](#extensible-adapter-system)

EdgeBinder features a powerful extensible adapter system that allows third-party developers to create custom adapters that work seamlessly across all PHP frameworks.

### Creating Third-Party Adapters

[](#creating-third-party-adapters)

```
// 1. Implement the adapter
class MyCustomAdapter implements PersistenceAdapterInterface { /* ... */ }

// 2. Create a factory
class MyCustomAdapterFactory implements AdapterFactoryInterface
{
    public function createAdapter(AdapterConfiguration $config): PersistenceAdapterInterface
    {
        $container = $config->getContainer();
        $instanceConfig = $config->getInstanceConfig();

        $client = $container->get($instanceConfig['my_client']);
        return new MyCustomAdapter($client, $instanceConfig);
    }

    public function getAdapterType(): string { return 'mycustom'; }
}

// 3. REQUIRED: Create compliance tests
use EdgeBinder\Testing\AbstractAdapterTestSuite;

class MyCustomAdapterTest extends AbstractAdapterTestSuite
{
    protected function createAdapter(): PersistenceAdapterInterface
    {
        return new MyCustomAdapter($this->setupClient());
    }

    protected function cleanupAdapter(): void
    {
        $this->teardownClient();
    }

    // 57+ comprehensive tests inherited automatically
}

// 4. Register in any framework
AdapterRegistry::register(new MyCustomAdapterFactory());

// 5. Use with consistent configuration
$edgeBinder = EdgeBinder::fromConfiguration([
    'adapter' => 'mycustom',
    'my_client' => 'my.service.client',
    'custom_option' => 'value',
], $container);
```

> **⚠️ CRITICAL**: All adapters must extend `AbstractAdapterTestSuite` to ensure 100% compliance. See the [Extensible Adapters Guide](docs/EXTENSIBLE_ADAPTERS.md) for details.

### Framework Integration

[](#framework-integration)

The same adapter works identically across all frameworks:

- **Laminas/Mezzio**: Register in `Module.php` or `ConfigProvider`
- **Symfony**: Register in bundle boot or compiler pass
- **Laravel**: Register in service provider boot method
- **Slim**: Register in application bootstrap
- **Generic PHP**: Register anywhere in application setup

### Documentation

[](#documentation)

- **[Extensible Adapters Guide](docs/EXTENSIBLE_ADAPTERS.md)** - Complete development guide
- **[Adapter Testing Standard](docs/ADAPTER_TESTING_STANDARD.md)** - **REQUIRED** compliance testing guide
- **[Framework Integration](docs/FRAMEWORK_INTEGRATION.md)** - Framework-specific examples
- **[Migration Guide](docs/MIGRATION_GUIDE.md)** - Converting existing adapters
- **[Future Development Plans](docs/FUTURE_PLANS.md)** - Roadmap and integration patterns
- **[Redis Adapter Example](examples/RedisAdapter/)** - Complete reference implementation

Related Projects
----------------

[](#related-projects)

- [EdgeBinder PDO Adapter](https://github.com/edgebinder/pdo-adapter) - SQL database adapter
- [EdgeBinder MongoDB Adapter](https://github.com/edgebinder/mongodb-adapter) - MongoDB adapter
- [EdgeBinder Weaviate Adapter](https://github.com/edgebinder/weaviate-adapter) - Vector database adapter

Support
-------

[](#support)

For issues and questions, please use the [GitHub issue tracker](https://github.com/EdgeBinder/edgebinder/issues).

License
-------

[](#license)

The Apache License (Apache-2.0). Please see [License File](LICENSE) for more information.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance58

Moderate activity, may be stable

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

15

Last Release

278d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bd5a2c6deedf2f52379d21fa55c9f5c6d0999b0ac1ca2ca2f33293e229107bfe?d=identicon)[iampersistent](/maintainers/iampersistent)

---

Top Contributors

[![iampersistent](https://avatars.githubusercontent.com/u/16964?v=4)](https://github.com/iampersistent "iampersistent (87 commits)")

---

Tags

metadataDomain Driven DesigndddgraphentitiesRelationshipsvector-database

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/edgebinder-edgebinder/health.svg)

```
[![Health](https://phpackages.com/badges/edgebinder-edgebinder/health.svg)](https://phpackages.com/packages/edgebinder-edgebinder)
```

###  Alternatives

[phpmentors/domain-kata

Kata for domain models

73426.9k9](/packages/phpmentors-domain-kata)[phpmentors/domain-commons

Commons for domain models

11287.8k](/packages/phpmentors-domain-commons)[ammardaana/laravel-domain-driven-design

Generate laravel Domain driven design (monolith) structure

111.2k](/packages/ammardaana-laravel-domain-driven-design)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
