PHPackages                             hejunjie/milvus - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. hejunjie/milvus

ActiveLibrary[Database &amp; ORM](/categories/database)

hejunjie/milvus
===============

一个轻量级的 PHP 库，用来通过 RESTful API 调用 Milvus 向量数据库，可以用它来管理集合、插入数据，以及进行向量搜索 | A lightweight PHP library for interacting with the Milvus vector database via RESTful API. It allows you to manage collections, insert data, and perform vector searches

v1.0.1(1mo ago)4185MITPHPPHP ^8.0

Since Sep 3Pushed 1mo agoCompare

[ Source](https://github.com/zxc7563598/php-milvus)[ Packagist](https://packagist.org/packages/hejunjie/milvus)[ RSS](/packages/hejunjie-milvus/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

hejunjie/milvus
===============

[](#hejunjiemilvus)

English ｜ [简体中文](./README.zh-CN.md)

A lightweight PHP library for interacting with the Milvus vector database via RESTful API — manage collections, insert data, and perform vector searches, all in one place.

**This project has been parsed by Zread. [Click here](https://zread.ai/zxc7563598/php-milvus) for a quick overview of the project structure.**

Requirements
------------

[](#requirements)

- PHP 8.0+
- ext-curl
- ext-json

Installation
------------

[](#installation)

```
composer require hejunjie/milvus
```

Quick Start
-----------

[](#quick-start)

```
use Hejunjie\Milvus;

// Initialize client (get the URL and API Key from Zilliz Cloud console)
$client = new Milvus\Client('https://xxx.api.zillizcloud.com', 'your-api-key');

// Create a collection
$client->collections()->create('my_collection', [
    'autoID' => true,
    'fields' => [
        ['fieldName' => 'id', 'dataType' => 'Int64', 'isPrimary' => true],
        ['fieldName' => 'vector', 'dataType' => 'FloatVector', 'elementTypeParams' => ['dim' => 128]],
        ['fieldName' => 'title', 'dataType' => 'VarChar', 'elementTypeParams' => ['max_length' => 256]],
    ]
]);

// Create an index (vector fields require an index before searching)
$client->indexes()->create('my_collection', [[
    'fieldName' => 'vector',
    'indexName' => 'vector_idx',
    'metricType' => 'COSINE',
    'indexConfig' => ['index_type' => 'AUTOINDEX'],
]]);

// Load the collection into memory
$client->collections()->load('my_collection');

// Insert data
$client->entities()->insert('my_collection', [
    ['vector' => array_fill(0, 128, 0.1), 'title' => 'First record'],
    ['vector' => array_fill(0, 128, 0.2), 'title' => 'Second record'],
]);

// Vector search
$results = $client->entities()->search('my_collection', [[
    'vector' => array_fill(0, 128, 0.15),
]], 'vector', limit: 10);
```

API Overview
------------

[](#api-overview)

All methods are accessed via chained calls, organized by module:

### Client

[](#client)

MethodDescription`customize($url, $params)`Custom request for calling APIs not yet wrapped### Collections

[](#collections)

MethodDescription`create($name, $schema, $indexParams)`Create a collection`describe($name)`Get collection details`drop($name)`Drop a collection`get_load_state($name)`Get collection load state`get_stats($name)`Get collection statistics`has($name)`Check if a collection exists`list()`List all collections`load($name)`Load a collection into memory`release($name)`Release a collection from memory`rename($name, $newName)`Rename a collection`alter_properties($name, $properties)`Set collection properties (e.g., TTL, mmap)`drop_properties($name, $keys)`Remove collection properties### Partitions

[](#partitions)

MethodDescription`create($collectionName, $partitionName)`Create a partition`drop($collectionName, $partitionName)`Drop a partition`get_stats($collectionName, $partitionName)`Get partition load state`has($collectionName, $partitionName)`Check if a partition exists`list($collectionName)`List all partitions`load($collectionName, $partitionNames)`Load partitions into memory`release($collectionName, $partitionNames)`Release partitions from memory### Indexes

[](#indexes)

MethodDescription`create($collectionName, $indexParams)`Create an index`describe($collectionName, $indexName)`Get index details`drop($collectionName, $indexName)`Drop an index`list($collectionName)`List all indexes### Aliases

[](#aliases)

MethodDescription`alter($collectionName, $aliasName)`Alter an alias`create($collectionName, $aliasName)`Create an alias`describe($collectionName, $aliasName)`Get alias details`drop($collectionName, $aliasName)`Drop an alias`list($collectionName)`List all aliases### Entities

[](#entities)

MethodDescription`insert($collectionName, $data, $partitionName)`Insert data`upsert($collectionName, $data, $partitionName)`Insert or update data`delete($collectionName, $filter, $partitionName)`Delete data by filter`get($collectionName, $ids, $outputFields, $partitionNames)`Get data by primary key`query($collectionName, $filter, $limit, $offset, $outputFields, $partitionNames)`Query data by filter`search($collectionName, $data, $annsField, $limit, $offset, $partitionNames)`Vector similarity searchNote

All methods have full PHPDoc comments with parameter details. For more information on Milvus RESTful API parameters, refer to the [Zilliz official documentation](https://docs.zilliz.com/docs/rest-api-overview).

Notes
-----

[](#notes)

- This library is built on Milvus RESTful API v2. Make sure your Milvus / Zilliz Cloud instance supports v2 endpoints.
- Before performing vector search, the collection must have an index created and be **loaded into memory** (via `load()`), otherwise the search will fail.
- Default request timeout is 10 seconds. Large data inserts may require batching.
- API Key can be `null` (for self-hosted Milvus without authentication), but is required for Zilliz Cloud managed service.

Motivation
----------

[](#motivation)

I was reading short stories on a novel site that didn't support search and had daily reading limits. Frustrated, I wrote a crawler to download all the stories — but then I couldn't find anything in them locally.

My tiny 2-core 2GB server couldn't run a Milvus instance, but Zilliz Cloud offers a free tier. I run vectorization on my Mac, and use SiliconFlow's free quota for vector queries during search. I just needed a PHP library to tie it all together — and that's how this library came to be.

Contributing
------------

[](#contributing)

If you find this library useful, give it a ⭐ Star, or submit an Issue / PR to share your ideas.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance93

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~314 days

Total

2

Last Release

34d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5b65d4b40ae456172fb38f63f84bf737ac88031484b1f228b1cc8d71baa80adf?d=identicon)[苏青安](/maintainers/%E8%8B%8F%E9%9D%92%E5%AE%89)

---

Top Contributors

[![zxc7563598](https://avatars.githubusercontent.com/u/46590942?v=4)](https://github.com/zxc7563598 "zxc7563598 (16 commits)")

### Embed Badge

![Health badge](/badges/hejunjie-milvus/health.svg)

```
[![Health](https://phpackages.com/badges/hejunjie-milvus/health.svg)](https://phpackages.com/packages/hejunjie-milvus)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.8k117.8M121](/packages/jdorn-sql-formatter)[backup-manager/backup-manager

A framework agnostic database backup manager with user-definable procedures and support for S3, Dropbox, FTP, SFTP, and more with drivers for popular frameworks.

1.7k1.6M11](/packages/backup-manager-backup-manager)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M88](/packages/propel-propel1)[insolita/yii2-migration-generator

Set of gii tools for generating files for migration by schema of table , phpdoc or table data

108508.0k5](/packages/insolita-yii2-migration-generator)[xpdo/xpdo

A PDO-based Object/Relational Bridge Library

7088.4k4](/packages/xpdo-xpdo)[voku/session2db

A PHP library acting as a wrapper for PHP's default session handling functions which stores data in a MySQL database, providing both better performance and better security and protection against session fixation and session hijacking.

2920.0k](/packages/voku-session2db)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
