edgebinder / edgebinder-laminas-component
Laminas/Mezzio integration component for EdgeBinder - A lightweight, storage-agnostic relationship management library
Requires
- php: ^8.3
- edgebinder/edgebinder: >=0.2.0 <1.0.0
- laminas/laminas-servicemanager: ^3.0 || ^4.0
- psr/container: ^1.0 || ^2.0
Requires (Dev)
- ergebnis/composer-normalize: ^2.39
- friendsofphp/php-cs-fixer: ^3.0
- phpstan/phpstan: ^1.10
- phpstan/phpstan-phpunit: ^1.3
- phpstan/phpstan-strict-rules: ^1.5
- phpunit/phpunit: ^11.0
README
A Laminas/Mezzio integration component for EdgeBinder - A lightweight, storage-agnostic relationship management library for PHP 8.3+.
Features
- 🏭 Service Factories - Ready-to-use factories for EdgeBinder instances
- 🔧 ConfigProvider - Seamless Laminas/Mezzio integration
- 🎯 Multi-Instance Support - Multiple EdgeBinder instances with different adapters
- 🔌 Extensible Adapters - Framework-agnostic plugin architecture
- 🛡️ Type Safety - Full PHP 8.3+ type safety with PHPStan level 8
- ⚡ Cross-Version Compatible - Supports ServiceManager 3.x/4.x and PSR-11 v1/v2
Requirements
- PHP 8.3+
- Laminas ServiceManager 3.0+ or 4.0+
- EdgeBinder ^0.2.0 (includes InMemoryAdapter for testing)
Installation
Install via Composer:
composer require edgebinder/edgebinder-laminas-component
Quick Start
1. Register the ConfigProvider
Add the ConfigProvider to your Laminas/Mezzio application:
// config/config.php use EdgeBinder\Component\ConfigProvider; $aggregator = new ConfigAggregator([ ConfigProvider::class, // ... other config providers ]);
2. Configure EdgeBinder
Copy the configuration template and customize it:
cp vendor/edgebinder/edgebinder-laminas-component/config/edgebinder.global.php.dist config/autoload/edgebinder.local.php
Or create configuration file manually:
// config/autoload/edgebinder.local.php return [ 'edgebinder' => [ // For testing and development 'adapter' => 'inmemory', // For production with Weaviate (requires edgebinder/weaviate-adapter) // 'adapter' => 'weaviate', // 'weaviate_client' => 'weaviate.client.default', // 'collection_name' => 'EdgeBindings', // 'schema' => [ // 'auto_create' => true, // 'vectorizer' => 'text2vec-openai', // ], ], ];
Adapters
EdgeBinder uses a self-determining adapter architecture. Adapters register themselves with the EdgeBinder AdapterRegistry when their packages are loaded.
Built-in Adapters
- InMemoryAdapter (
inmemory
) - Included with EdgeBinder core v0.2.0+, perfect for testing and development
Available Adapters
- WeaviateAdapter (
weaviate
) - Installedgebinder/weaviate-adapter
for vector database support - JanusAdapter (
janus
) - Installedgebinder/janus-adapter
for graph database support - RedisAdapter (
redis
) - Installedgebinder/redis-adapter
for caching and fast lookups
3. Use in Your Services
use EdgeBinder\EdgeBinder; use Psr\Container\ContainerInterface; class MyService { public function __construct(private EdgeBinder $edgeBinder) {} public function createRelationship($document, $knowledgeBase): void { $this->edgeBinder->bind( from: $document, to: $knowledgeBase, type: 'belongs_to', metadata: [ 'relevance_score' => 0.95, 'semantic_similarity' => 0.87, ] ); } } // Factory class MyServiceFactory { public function __invoke(ContainerInterface $container): MyService { return new MyService($container->get(EdgeBinder::class)); } }
Multiple Instances
Configure multiple EdgeBinder instances for different use cases:
// config/autoload/edgebinder.local.php return [ 'edgebinder' => [ // RAG system with vector search 'rag' => [ 'adapter' => 'weaviate', 'weaviate_client' => 'weaviate.client.rag', 'collection_name' => 'RAGBindings', 'schema' => ['vectorizer' => 'text2vec-openai'], ], // Analytics with graph database 'analytics' => [ 'adapter' => 'janus', 'janus_client' => 'janus.client.analytics', 'graph_name' => 'AnalyticsGraph', ], // Fast cache lookups 'cache' => [ 'adapter' => 'redis', 'redis_client' => 'redis.client.cache', 'ttl' => 3600, ], // Testing instance 'test' => [ 'adapter' => 'inmemory', ], ], ];
Register named instances in your container:
// config/autoload/dependencies.local.php return [ 'dependencies' => [ 'factories' => [ 'edgebinder.rag' => function(ContainerInterface $container) { $factory = new EdgeBinderFactory(); return $factory->createEdgeBinder($container, 'rag'); }, 'edgebinder.analytics' => function(ContainerInterface $container) { $factory = new EdgeBinderFactory(); return $factory->createEdgeBinder($container, 'analytics'); }, 'edgebinder.test' => function(ContainerInterface $container) { $factory = new EdgeBinderFactory(); return $factory->createEdgeBinder($container, 'test'); }, ], ], ]; 'rag' => [ 'adapter' => 'weaviate', 'weaviate_client' => 'weaviate.client.rag', 'collection_name' => 'RAGBindings', ], 'analytics' => [ 'adapter' => 'weaviate', 'weaviate_client' => 'weaviate.client.analytics', 'collection_name' => 'AnalyticsBindings', ], ], ];
Use named instances:
$ragBinder = $container->get('edgebinder.rag'); $analyticsBinder = $container->get('edgebinder.analytics');
Documentation
Contributing
Please see CONTRIBUTING.md for details.
License
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.