symfony/ai-neo4j-store
Neo4j Store integration for Symfony AI Store, enabling use of Neo4j as a vector store with support for vector indexes. Includes links to Neo4j documentation and Symfony AI resources for contributing and reporting issues.
symfony/ai-memory-store for lightweight use cases.neo4j-php-client. Laravel can host this via Docker or a managed service (e.g., AuraDB).CREATE SEMANTIC INDEX `embedding_index`
FOR (n:Node)
OPTIONS {indexConfig: {
`vector.dimensions`: 768,
`vector.similarity_function`: 'cosine'
}}
VectorStoreInterface to the Neo4j store. Example:
$this->app->bind(\Symfony\Component\AI\VectorStoreInterface::class, function ($app) {
return new \Symfony\Component\AI\Store\Neo4jStore(
new \Neo4j\ClientBuilder()->withUri(env('NEO4J_URI'))->build()
);
});
LOAD CSV or custom scripts. Example:
LOAD CSV WITH HEADERS FROM 'file:///data.csv' AS row
CREATE (:Document {text: row.content, embedding: apoc.convert.fromJsonList(row.vector)})
| Risk | Mitigation |
|---|---|
| Neo4j Driver Instability | Pin neo4j/neo4j-php-client to a stable version (e.g., ^5.0). Test with Laravel’s PHP unit. |
| Symfony Laravel Incompatibility | Abstract Symfony interfaces behind Laravel contracts (e.g., VectorStoreInterface). |
| Vector Index Performance | Benchmark with real-world queries (e.g., MATCH (n) WHERE vectorSimilarity(n.embedding, $query) > 0.8). |
| Schema Rigidity | Design flexible Neo4j labels (e.g., :Document, :Entity) to avoid costly migrations. |
| Neo4j Licensing Costs | Evaluate AuraDB (managed) or community edition for cost-sensitive projects. |
pgvector) suffice?author = X AND year > 2020").VectorStoreInterface directly (if Laravel can tolerate Symfony dependencies).namespace App\Services;
use Symfony\Component\AI\VectorStoreInterface;
use Neo4j\ClientBuilder;
class Neo4jVectorStore implements \Symfony\Component\AI\VectorStoreInterface {
public function __construct(private VectorStoreInterface $store) {}
// Delegate to Symfony store...
}
neo4j/neo4j-php-client (v5+ for vector support).Post → :Document with embedding property).:Document {text: string, embedding: float[], category: string}).LOAD CSV or Laravel jobs to import data:
// Example Laravel job for bulk import
public function handle() {
$records = Model::all()->toArray();
$this->neo4jClient->run('UNWIND $records AS r CREATE (:Document {text: r.content, embedding: r.vector})', ['records' => $records]);
}
composer require symfony/ai-neo4j-store neo4j/neo4j-php-client
AppServiceProvider:
public function register() {
$this->app->singleton(\Symfony\Component\AI\VectorStoreInterface::class, function ($app) {
return new \Symfony\Component\AI\Store\Neo4jStore(
new \Neo4j\ClientBuilder()->withUri(env('NEO4J_URI'))->build()
);
});
}
$store = app(\Symfony\Component\AI\VectorStoreInterface::class);
$store->add([1.0, 2.0, 3.0]); // Test embedding insertion
$results = $store->similaritySearch([1.1, 2.1, 3.1]); // Test retrieval
composer.json for symfony/ai version).add()/similaritySearch().EXPLAIN queries).vector.dimensions).How can I help you explore Laravel packages today?