adachsoft/vector-store-json-file
Composer 安装命令:
composer require adachsoft/vector-store-json-file
包简介
JSON file based implementation of vector store contracts
README 文档
README
Overview
adachsoft/vector-store-json-file is a file-based implementation of the VectorStoreInterface from the adachsoft/vector-store-contracts package.
Each vector collection is stored as a single JSON file on disk. The JSON file contains:
- global configuration of the collection (dimensions, distance metric),
- all vector records (embeddings),
- arbitrary metadata attached to each record.
This package is intended for small to medium vector stores where a simple JSON file is sufficient and a database or external service would be overkill.
Requirements
- PHP 8.3 or higher
- Composer
- Runtime dependencies:
adachsoft/vector-store-contracts(vector store contracts and DTOs)adachsoft/collection(immutable collections for vectors and metadata)
Installation
Install the package via Composer:
composer require adachsoft/vector-store-json-file
Usage
Basic store setup
use AdachSoft\VectorStoreJsonFile\JsonFileVectorStore;
use AdachSoft\VectorStoreContracts\Enum\DistanceMetricEnum;
$storagePath = __DIR__ . '/var/vector-store';
// Create the store instance (the directory must exist and be writable)
$store = new JsonFileVectorStore($storagePath);
// Create a new collection backed by a single JSON file
$store->createCollection('documents', 384, DistanceMetricEnum::COSINE);
// Get a repository for this collection
$repository = $store->getCollection('documents');
Upserting and searching
use AdachSoft\VectorStoreContracts\Dto\VectorRecordDto;
use AdachSoft\VectorStoreContracts\Dto\SearchQueryDto;
use AdachSoft\VectorStoreContracts\Collection\FilterCollection;
// Upsert a vector record
$record = new VectorRecordDto(
'doc-123',
// 384-dimensional vector (example values)
[0.1, 0.2, 0.3, 0.4 /* ... */],
['category' => 'technology', 'language' => 'en']
);
$repository->upsert($record);
// Build a search query
$query = new SearchQueryDto(
[0.11, 0.21, 0.31, 0.41 /* ... */], // query vector
5, // topK
null, // optional minimum score
new FilterCollection(['language' => 'en'])
);
// Execute the search
$results = $repository->search($query);
foreach ($results as $result) {
$record = $result->record;
$score = $result->score;
// Handle the result (e.g. display ID and score)
}
Using the factory
If you prefer configuration-based creation, you can use the factory:
use AdachSoft\VectorStoreJsonFile\JsonFileVectorStoreFactory;
$factory = new JsonFileVectorStoreFactory();
$store = $factory->create([
'storage_path' => __DIR__ . '/var/vector-store',
]);
Testing
This project includes a test suite based on the contract tests from
adachsoft/vector-store-contracts.
Run tests with:
vendor/bin/phpunit
The test configuration is defined in phpunit.xml in the project root.
Code style and static analysis
The project uses adachsoft/php-code-style
for a unified code style, Rector rules and PHPStan configuration.
Convenience Composer scripts:
composer cs:check # run PHP-CS-Fixer in dry-run mode
composer cs:fix # fix coding style issues
composer stan # run PHPStan analysis
composer rector # run Rector refactorings
License
This library is open-sourced under the MIT license. See the license field in
composer.json for details.
adachsoft/vector-store-json-file 适用场景与选型建议
adachsoft/vector-store-json-file 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「json」 「php-library」 「embeddings」 「semantic-search」 「vector-store」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 adachsoft/vector-store-json-file 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 adachsoft/vector-store-json-file 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 adachsoft/vector-store-json-file 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Kinikit - PHP Application development framework MVC component
PHP Interface for Babel Street Text Analytics
ext-json wrapper with sane defaults
Laravel AI SDK provider extension that adds Seeweb Regolo — chat, embeddings, reranking, plus a 30+ open-model catalog hosted in Italy — as a first-class provider for the official laravel/ai SDK.
Initialize Script
A package to cast json fields, each sub-keys is castable
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 44
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-13