1. Go to this page and download the library: Download edgebinder/weaviate-adapter library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
edgebinder / weaviate-adapter example snippets
use EdgeBinder\EdgeBinder;
use EdgeBinder\Adapter\Weaviate\WeaviateAdapterFactory;
use EdgeBinder\Registry\AdapterRegistry;
use Weaviate\WeaviateClient;
// Register the Weaviate adapter factory
AdapterRegistry::register(new WeaviateAdapterFactory());
// Configure your container to provide the Weaviate client
$container = /* your PSR-11 container */;
// Create EdgeBinder using configuration
$config = [
'adapter' => 'weaviate',
'weaviate_client' => 'weaviate.client.default',
'collection_name' => 'MyAppBindings',
'schema' => [
'auto_create' => true,
'vectorizer' => 'text2vec-openai'
]
];
$binder = EdgeBinder::fromConfiguration($config, $container);
// Use EdgeBinder as normal
$workspace = new Entity('workspace-123', 'Workspace');
$project = new Entity('project-456', 'Project');
$binding = $binder->bind(
from: $workspace,
to: $project,
type: 'has_access',
metadata: [
'access_level' => 'write',
'granted_by' => 'user-789',
'confidence_score' => 0.95
]
);
use EdgeBinder\EdgeBinder;
use EdgeBinder\Adapter\Weaviate\WeaviateAdapter;
use Weaviate\WeaviateClient;
// Connect to Weaviate
$weaviateClient = WeaviateClient::connectToLocal();
// Create the adapter directly
$adapter = new WeaviateAdapter($weaviateClient, [
'collection_name' => 'MyAppBindings',
'schema' => [
'auto_create' => true,
'vectorizer' => 'text2vec-openai'
]
]);
// Create EdgeBinder instance
$binder = EdgeBinder::fromAdapter($adapter);
// In your Module.php or application bootstrap
use EdgeBinder\Adapter\Weaviate\WeaviateAdapterFactory;
use EdgeBinder\Registry\AdapterRegistry;
AdapterRegistry::register(new WeaviateAdapterFactory());
// In your service factory
public function __invoke(ContainerInterface $container): EdgeBinder
{
$config = $container->get('config')['edgebinder']['rag'];
return EdgeBinder::fromConfiguration($config, $container);
}
// In your bundle boot method or compiler pass
use EdgeBinder\Adapter\Weaviate\WeaviateAdapterFactory;
use EdgeBinder\Registry\AdapterRegistry;
AdapterRegistry::register(new WeaviateAdapterFactory());
// In your service
public function createEdgeBinder(ContainerInterface $container): EdgeBinder
{
$config = $container->getParameter('edgebinder.rag');
return EdgeBinder::fromConfiguration($config, $container);
}
// In your service provider boot method
use EdgeBinder\Adapter\Weaviate\WeaviateAdapterFactory;
use EdgeBinder\Registry\AdapterRegistry;
public function boot()
{
AdapterRegistry::register(new WeaviateAdapterFactory());
}
// In your service
public function createEdgeBinder(): EdgeBinder
{
$config = config('edgebinder.rag');
return EdgeBinder::fromConfiguration($config, app());
}