Download the PHP package helgesverre/milvus without Composer
On this page you can find all versions of the php package helgesverre/milvus. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download helgesverre/milvus
More information about helgesverre/milvus
Files in helgesverre/milvus
Package milvus
Short Description PHP Client for the Milvus Rest API
License MIT
Homepage https://github.com/helgesverre/milvus
Informations about the package milvus
Milvus.io PHP API Client
Milvus is an open-source vector database that is highly flexible, reliable, and blazing fast. It supports adding, deleting, updating, and near real-time search of vectors on a trillion-byte scale.
This package is a PHP client for the stable Milvus REST v2 endpoints shared by Milvus 2.5 through 3.0. It is tested against Milvus 2.5.21, 2.6.21, and 3.0.0, and built on Saloon.
See the Milvus REST API documentation and the official database, collection, and vector OpenAPI definitions.
See the changelog for the complete release history and upgrade notes.
Compatibility
The supported runtime matrix is PHP 8.3–8.5 and Laravel 12–13. Laravel 10 and 11 remain covered by compatibility
tests for existing applications, but both framework versions are end-of-life and should not be used for new
installations. Their CI jobs use Composer's command-scoped --no-blocking option because current Composer versions
block their affected upstream framework releases.
| Laravel Version | Tested PHP | Status |
|---|---|---|
| 13.x | 8.5 | Supported |
| 12.x | 8.4 | Supported |
| 11.x | 8.3 | Legacy compatibility |
| 10.x | 8.3 | Legacy compatibility |
Versions
| Milvus Version | PHP Client Version |
|---|---|
| v3.0.x | v0.2.0+ |
| v2.6.x | v0.2.0+ |
| v2.5.x | v0.2.0+ |
| v2.3.x | v0.0.x-v0.1.x |
PHP 8.3–8.5 is supported. Laravel is optional; the client can also be used as a standalone Saloon connector.
Installation
You can install the package via composer:
You can publish the config file with:
This is the contents of the published config/milvus.php file:
MILVUS_TOKEN takes precedence. When it is absent, the Laravel service provider builds the token from a complete
MILVUS_USERNAME and MILVUS_PASSWORD pair. Milvus expects that credential token in raw username:password format.
Usage
With Laravel
For Laravel users, you can use the Milvus facade to interact with the Milvus API:
Managing databases
Database operations use the Milvus REST v2 database endpoints. The REST API is stateless, so pass dbName to each
collection or vector operation that should run outside the default database.
The default database cannot be dropped, and a database must have no collections before it can be dropped. Database
list and describe responses expose databases and database; database IDs remain strings if they exceed PHP's
integer range.
Filtering vector searches
Use filter to restrict similarity search by scalar fields. data is an array of query vectors and annsField is
the collection's vector field. Scalar fields must be part of the collection schema or accepted by its dynamic field.
The same Milvus expression syntax works for query() and delete(), including expressions such as
id in [1, 2, 3] and status == "published".
Custom schemas and AutoID
For explicit field control, pass a custom schema. Field options follow the Milvus REST schema unchanged:
With quick setup, set autoID: true and omit the primary key from inserted rows. The mutation DTO returns generated
IDs through $response->dto()->result->insertIds.
Milvus 3 features
Milvus 3 can search using existing entity IDs instead of providing a vector directly:
Partial upserts let you update scalar fields without resending the vector:
Without Laravel
Without Laravel, create a Milvus instance with a token, host, and port. For username/password authentication, pass
the raw username:password value as the token.
The connector exposes the same methods shown above; replace Milvus:: with $milvus->.
Typed responses
Every request still returns a Saloon response, so existing json() and collect() calls continue to work. Call
dto() when you want a validated response object:
Milvus can report API failures with HTTP status 200, so use throwIfFailed() when handling a DTO. It throws a
MilvusApiException containing the Milvus error code. Malformed success payloads throw InvalidResponseException
instead of silently returning partial data.
The response types are EmptyResponse for create/drop, DatabaseListResponse, DatabaseDescriptionResponse,
CollectionListResponse, CollectionDescriptionResponse, MutationResponse for insert/upsert/delete,
EntityResponse for get/query, and SearchResponse. Dynamic entity fields and unknown future response fields remain
available through raw.
Using with Zilliz Cloud
Milvus v0.2 and newer automatically uses the /v2/vectordb/... endpoints; do not include an API version or operation
path in the host. For Zilliz Cloud, pass the HTTPS cluster endpoint, port 443, and your API key as the token:
Existing applications that still send requests to /v1/vector/... should upgrade with
composer require helgesverre/milvus:^0.2.
Example: Semantic Search with Milvus and OpenAI Embeddings
This example demonstrates how to perform a semantic search in Milvus using embeddings generated from OpenAI.
Prepare Your Data
First, create an array of data you wish to index. In this example, we'll use blog posts with titles, summaries, and tags.
Generate Embeddings
Use OpenAI's embeddings API to convert the summaries of your blog posts into vector embeddings.
Create Milvus collection
Create a collection in Milvus to store your blog post embeddings, note that the dimension of the embeddings must match
the dimension of the embeddings generated by OpenAI (1536 if you are using the text-embedding-ada-002 model).
Insert into Milvus
Insert these embeddings, along with other blog post data, into your Milvus collection.
Creating a Search Vector with OpenAI
Generate a search vector for your query, akin to how you processed the blog posts.
Searching using the Embedding in Milvus
Use the Milvus client to perform a search with the generated embedding.
Running Milvus in Docker
To quickly get started with Milvus, you can run it in Docker, by using the following command
A healthcheck endpoint will now be available on http://localhost:9091/healthz, and the Milvus API will be available
on http://localhost:19530.
To stop Milvus, run docker compose down. Data is stored in the local volumes/ directory.
For more details Installing Milvus Standalone with Docker Compose
For production workloads, consider checking out Zilliz.com, which are the developers behind Milvus and provides a hosted version of Milvus in the Cloud ☁️.
Testing
The fast suite verifies request serialization, response decoding and edge cases, authentication, Laravel service-provider resolution, and architecture rules without contacting Milvus:
The full test command starts Docker and runs both the unit suite and live full-client smoke, database, collection, custom-schema, AutoID, filtered-search, error-envelope, and response-DTO scenarios:
To run only the integration suite against a specific supported Milvus version:
Run the remaining release checks with:
CI repeats the integration test against Milvus 2.5.21, 2.6.21, and 3.0.0, and runs the package suite across PHP 8.3–8.5 and Laravel 10–13.
License
The MIT License (MIT). Please see License File for more information.
Disclaimer
"Milvus®" and the Milvus logo are registered trademarks of the Linux Foundation (LF Projects, LLC). This package is not affiliated with, endorsed by, or sponsored by the Linux Foundation. It's developed independently and uses the "Milvus" name under fair use, solely for identification. All trademarks and registered trademarks, including "Milvus®", are the property of their respective owners. "Milvus®" is a registered trademark of the Linux Foundation.