# PHPVector

A pure-PHP vector database implementing HNSW approximate nearest-neighbour search and BM25 full-text retrieval, which can be combined into a hybrid search pipeline.

PHPVector implements HNSW (Hierarchical Navigable Small World) search for approximate nearest-neighbour vector queries and BM25 for full-text retrieval, entirely in PHP with no external extensions required for core functionality; an optional pcntl extension enables asynchronous document writes for lower insert latency. It requires PHP 8.2 or newer and installs through Composer.

A document holds a dense embedding vector, optional raw text for BM25 matching, and arbitrary metadata, with an automatically generated UUID if none is given. Hybrid search offers reciprocal rank fusion, which is rank-based, scale-invariant and needs no tuning, or a weighted combination that normalizes both score ranges before applying explicit vector and text weights.

Both the HNSW and BM25 engines are fully configurable through config objects passed to the database constructor.

Website: https://github.com/ezimuel/PHPVector
