{"id":18486106,"url":"https://github.com/mathsgod/milvus-client-php","last_synced_at":"2026-03-10T19:32:09.951Z","repository":{"id":248044389,"uuid":"639770740","full_name":"mathsgod/milvus-client-php","owner":"mathsgod","description":"A PHP client for Milvus","archived":false,"fork":false,"pushed_at":"2025-08-19T02:57:36.000Z","size":299,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-22T02:22:44.975Z","etag":null,"topics":["milvus"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mathsgod.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-05-12T07:30:40.000Z","updated_at":"2025-08-19T02:57:40.000Z","dependencies_parsed_at":"2025-08-12T09:14:08.051Z","dependency_job_id":null,"html_url":"https://github.com/mathsgod/milvus-client-php","commit_stats":null,"previous_names":["mathsgod/milvus-client-php"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/mathsgod/milvus-client-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathsgod%2Fmilvus-client-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathsgod%2Fmilvus-client-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathsgod%2Fmilvus-client-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathsgod%2Fmilvus-client-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mathsgod","download_url":"https://codeload.github.com/mathsgod/milvus-client-php/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathsgod%2Fmilvus-client-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30350064,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T15:55:29.454Z","status":"ssl_error","status_checked_at":"2026-03-10T15:54:58.440Z","response_time":106,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["milvus"],"created_at":"2024-11-06T12:47:52.604Z","updated_at":"2026-03-10T19:32:09.944Z","avatar_url":"https://github.com/mathsgod.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# milvus-client-php\n\nA PHP client for [Milvus](https://milvus.io/) 2.6.x.\n\n## Installation\n\n```bash\ncomposer require mathsgod/milvus-client-php\n```\n\n## Quick Start\n\n### Initialize Client\n\n```php\nuse Milvus\\Client;\n\n$client = new Client(\n    \"http://localhost:19530\", // Milvus server URI\n    \"username\",               // Optional: username\n    \"password\",               // Optional: password\n    \"default\",                // Optional: database name\n    \"token\"                   // Optional: JWT token\n);\n```\n\n---\n\n## Example: Create Collection with Various Field Types and Search\n\n```php\n$client = new Milvus\\Client();\n\n$client-\u003ecreateCollection(\n    collection_name: \"testing\",\n    schema: $client-\u003ecreateSchema()\n        -\u003eaddField(\"id\", Milvus\\DataType::INT64, is_primary: true)\n        -\u003eaddField(\"array\", Milvus\\DataType::ARRAY, element_type: Milvus\\DataType::INT64, max_capacity: 10)\n        -\u003eaddField(\"vector\", Milvus\\DataType::FLOAT_VECTOR, dim: 5)\n        -\u003eaddField(\"text\", Milvus\\DataType::VARCHAR, max_length: 1000, nullable: true)\n        -\u003eaddField(\"metadata\", Milvus\\DataType::JSON, nullable: true),\n    index_params: $client-\u003eprepareIndexParams()\n        -\u003eaddIndex(\n            field_name: \"vector\",\n            index_name: \"my_index\",\n            index_type: Milvus\\IndexType::AUTOINDEX,\n            metric_type: Milvus\\MetricType::COSINE\n        ),\n);\n\n// Insert data\n$client-\u003einsert(\n    collection_name: \"testing\",\n    data: [\n        [\n            \"id\" =\u003e 1,\n            \"array\" =\u003e [1, 2, 3],\n            \"vector\" =\u003e [0.1, 0.2, 0.3, 0.4, 0.5],\n            \"text\" =\u003e \"Hello World\",\n            \"metadata\" =\u003e [\"key1\" =\u003e \"value1\", \"key2\" =\u003e \"value2\"]\n        ],\n        [\n            \"id\" =\u003e 2,\n            \"array\" =\u003e [4, 5, 6],\n            \"vector\" =\u003e [0.6, 0.7, 0.8, 0.9, 1.0],\n            \"text\" =\u003e null,\n            \"metadata\" =\u003e null\n        ]\n    ]\n);\n\nprint_R($client-\u003esearch(\n    collection_name: \"testing\",\n    data: [[0.1, 0.2, 0.3, 0.4, 0.5]],\n    anns_field: \"vector\",\n    limit: 3,\n    output_fields: [\"id\", \"vector\", \"text\", \"metadata\"],\n));\n```\n\n#### Example Search Result\n\n```php\nArray\n(\n    [0] =\u003e Array\n        (\n            [distance] =\u003e 0.99999994\n            [id] =\u003e 1\n            [metadata] =\u003e {\"key1\":\"value1\",\"key2\":\"value2\"}\n            [text] =\u003e Hello World\n            [vector] =\u003e Array\n                (\n                    [0] =\u003e 0.1\n                    [1] =\u003e 0.2\n                    [2] =\u003e 0.3\n                    [3] =\u003e 0.4\n                    [4] =\u003e 0.5\n                )\n\n        )\n\n    [1] =\u003e Array\n        (\n            [distance] =\u003e 0.96495044\n            [id] =\u003e 2\n            [metadata] =\u003e\n            [text] =\u003e\n            [vector] =\u003e Array\n                (\n                    [0] =\u003e 0.6\n                    [1] =\u003e 0.7\n                    [2] =\u003e 0.8\n                    [3] =\u003e 0.9\n                    [4] =\u003e 1\n                )\n\n        )\n\n)\n```\n\n---\n\n## Full-Text Search Example\n\n```php\n$client = new Milvus\\Client();\n\n$client-\u003edropCollection(\"testing2\");\n\n// Full-Text Search\n\n$client-\u003ecreateCollection(\n    collection_name: \"testing2\",\n    schema: $client-\u003ecreateSchema()\n        -\u003eaddField(\"id\", Milvus\\DataType::INT64, is_primary: true)\n        -\u003eaddField(\"text_sparse\", Milvus\\DataType::SPARSE_FLOAT_VECTOR)\n        -\u003eaddField(\"document\", Milvus\\DataType::VARCHAR, max_length: 1000, enable_analyzer: true, enable_match: true)\n        -\u003eaddFunction(\n            name: \"bm25\",\n            function_type: Milvus\\FunctionType::BM25,\n            input_field_names: [\"document\"],\n            output_field_names: [\"text_sparse\"]\n        ),\n    index_params: $client-\u003eprepareIndexParams()\n        -\u003eaddIndex(\n            field_name: \"text_sparse\",\n            index_name: \"text_sparse_index\",\n            index_type: Milvus\\IndexType::SPARSE_INVERTED_INDEX,\n            metric_type: Milvus\\MetricType::BM25\n        ),\n);\n\n// Insert data\n$client-\u003einsert(\n    collection_name: \"testing2\",\n    data: [\n        [\n            \"id\" =\u003e 1,\n            \"document\" =\u003e \"This is a sample document for testing.\",\n        ],\n        [\n            \"id\" =\u003e 2,\n            \"document\" =\u003e \"Another document for testing purposes.\",\n        ],\n        [\n            \"id\" =\u003e 3,\n            \"document\" =\u003e \"Milvus is a vector database designed for scalable similarity search.\",\n        ],\n        [\n            \"id\" =\u003e 4,\n            \"document\" =\u003e \"Full-text search enables users to find relevant documents quickly.\",\n        ],\n        [\n            \"id\" =\u003e 5,\n            \"document\" =\u003e \"This document contains information about PHP and Milvus integration.\",\n        ],\n        [\n            \"id\" =\u003e 6,\n            \"document\" =\u003e \"Testing the search functionality with various sample documents.\",\n        ],\n        [\n            \"id\" =\u003e 7,\n            \"document\" =\u003e \"Another example document to increase the dataset size.\",\n        ],\n        [\n            \"id\" =\u003e 8,\n            \"document\" =\u003e \"Sample data helps in validating the search and indexing features.\",\n        ]\n    ]\n);\n\nprint_r($client-\u003esearch(\n    collection_name: \"testing2\",\n    data: ['sample'],\n    anns_field: \"text_sparse\",\n    limit: 5\n));\n```\n\n---\n\n## Text Embedding Example\n\nFor more details about embedding functions, please refer to [Milvus Embedding Function Overview](https://milvus.io/docs/embedding-function-overview.md).\n\n```php\n$client = new Milvus\\Client();\n\n// Text Embedding with Azure OpenAI\n$client-\u003ecreateCollection(\n    collection_name: \"testing\",\n    schema: $client-\u003ecreateSchema()\n        -\u003eaddField(\"id\", Milvus\\DataType::INT64, is_primary: true)\n        -\u003eaddField(\"document\", Milvus\\DataType::VARCHAR, max_length: 1000, enable_analyzer: true, enable_match: true)\n        -\u003eaddField(\"dense\", Milvus\\DataType::FLOAT_VECTOR, dim: 1536)\n        -\u003eaddFunction(\n            name: \"azure_embedding\",\n            function_type: Milvus\\FunctionType::TEXT_EMBEDDING,\n            input_field_names: [\"document\"],\n            output_field_names: [\"dense\"],\n            params: [\n                \"provider\" =\u003e \"azure_openai\",\n                \"model_name\" =\u003e \"text-embedding-3-small\"\n            ]\n        ),\n    index_params: $client-\u003eprepareIndexParams()\n        -\u003eaddIndex(\n            field_name: \"dense\",\n            index_name: \"dense_index\",\n            index_type: Milvus\\IndexType::AUTOINDEX,\n            metric_type: Milvus\\MetricType::COSINE\n        ),\n);\n\n// Insert data (embeddings will be automatically generated)\n$client-\u003einsert(\n    collection_name: \"testing\",\n    data: [\n        [\n            \"id\" =\u003e 1,\n            \"document\" =\u003e \"This is a sample document for embedding.\",\n        ],\n        [\n            \"id\" =\u003e 2,\n            \"document\" =\u003e \"Another document to test text embedding functionality.\",\n        ],\n        [\n            \"id\" =\u003e 3,\n            \"document\" =\u003e \"Milvus supports automatic text embedding generation.\",\n        ],\n        [\n            \"id\" =\u003e 4,\n            \"document\" =\u003e \"Azure OpenAI provides powerful embedding models.\",\n        ]\n    ]\n);\n\n// Search using embedding (the query text will be automatically embedded)\nprint_r($client-\u003esearch(\n    collection_name: \"testing\",\n    data: [\"sample document embedding\"],\n    anns_field: \"dense\",\n    limit: 3,\n    output_fields: [\"id\", \"document\"]\n));\n```\n\n#### Example Search Result\n\n```php\nArray\n(\n    [0] =\u003e Array\n        (\n            [distance] =\u003e 0.712204\n            [document] =\u003e This is a sample document for embedding.\n            [id] =\u003e 1\n        )\n\n    [1] =\u003e Array\n        (\n            [distance] =\u003e 0.6992143\n            [document] =\u003e Another document to test text embedding functionality.\n            [id] =\u003e 2\n        )\n\n    [2] =\u003e Array\n        (\n            [distance] =\u003e 0.43827245\n            [document] =\u003e Azure OpenAI provides powerful embedding models.\n            [id] =\u003e 4\n        )\n\n)\n```\n\n---\n\n## Hybrid Search Example\n\n```php\n$client = new Milvus\\Client();\n\n$client-\u003edropCollection(\"testing\");\n\n// Hybrid Search\n$client-\u003ecreateCollection(\n    collection_name: \"testing\",\n    schema: $client-\u003ecreateSchema()\n        -\u003eaddField(\"id\", Milvus\\DataType::INT64, is_primary: true)\n        -\u003eaddField(\"vector\", Milvus\\DataType::FLOAT_VECTOR, dim: 5)\n        -\u003eaddField(\"document\", Milvus\\DataType::VARCHAR, max_length: 1000, enable_analyzer: true, enable_match: true)\n        -\u003eaddField(\"text_sparse\", Milvus\\DataType::SPARSE_FLOAT_VECTOR)\n        -\u003eaddFunction(\n            name: \"bm25\",\n            function_type: Milvus\\FunctionType::BM25,\n            input_field_names: [\"document\"],\n            output_field_names: [\"text_sparse\"]\n        ),\n    index_params: $client-\u003eprepareIndexParams()\n        -\u003eaddIndex(\n            field_name: \"vector\",\n            index_name: \"my_index\",\n            index_type: Milvus\\IndexType::AUTOINDEX,\n            metric_type: Milvus\\MetricType::COSINE\n        )-\u003eaddIndex(\n            field_name: \"text_sparse\",\n            index_name: \"text_sparse_index\",\n            index_type: Milvus\\IndexType::SPARSE_INVERTED_INDEX,\n            metric_type: Milvus\\MetricType::BM25\n        ),\n);\n\n// Insert data\n$client-\u003einsert(\n    collection_name: \"testing\",\n    data: [\n        [\n            \"id\" =\u003e 1,\n            \"vector\" =\u003e [0.1, 0.2, 0.3, 0.4, 0.5],\n            \"document\" =\u003e \"This is a sample document for testing.\",\n        ],\n        [\n            \"id\" =\u003e 2,\n            \"vector\" =\u003e [0.6, 0.7, 0.8, 0.9, 1.0],\n            \"document\" =\u003e \"Another document for testing purposes.\",\n        ],\n        [\n            \"id\" =\u003e 3,\n            \"vector\" =\u003e [0.1, 0.2, 0.3, 0.4, 0.5],\n            \"document\" =\u003e \"Milvus is a vector database designed for scalable similarity search.\",\n        ],\n        [\n            \"id\" =\u003e 4,\n            \"vector\" =\u003e [0.6, 0.7, 0.8, 0.9, 1.0],\n            \"document\" =\u003e \"Full-text search enables users to find relevant documents quickly.\",\n        ],\n    ]\n);\n\n$query = \"sample document\";\n\nprint_r($client-\u003ehybridSearch(\n    collection_name: \"testing\",\n    search: [\n        new HybridSearchRequest(\n            data: [[0.1, 0.2, 0.3, 0.4, 0.5]], // embedding vector of the query\n            anns_field: \"vector\",\n            limit: 10,\n            param: [\"nprobe\" =\u003e 10] // search parameters\n        ),\n        new HybridSearchRequest(\n            data: [$query], // query string\n            anns_field: \"text_sparse\",\n            limit: 10,\n            param: [\"drop_ratio_search\" =\u003e 0.2]\n        )\n    ],\n    ranker: new WeightedRanker([0.5, 0.5]),\n    output_fields: [\"id\", \"document\"]\n));\n```\n\n---\n\n## Database Operations\n\n### Create Database\n\n```php\n$client-\u003ecreateDatabase(\"my_db\");\n```\n\n### Switch Database\n\n```php\n$client-\u003eusingDatabase(\"my_db\");\n```\n\n### List All Databases\n\n```php\n$dbs = $client-\u003elistDatabases();\n```\n\n### Describe Database\n\n```php\n$info = $client-\u003edescribeDatabase(\"my_db\");\n```\n\n### Drop Database\n\n```php\n$client-\u003edropDatabase(\"my_db\");\n```\n\n---\n\n## Collection Operations\n\n### Create Collection\n\n```php\n$client-\u003ecreateCollection(\n    collection_name: \"test_collection\",\n    schema: $client-\u003ecreateSchema()\n        -\u003eaddField(\"id\", Milvus\\DataType::INT64, is_primary: true)\n        -\u003eaddField(\"array\", Milvus\\DataType::ARRAY, element_type: Milvus\\DataType::INT64, max_capacity: 10)\n        -\u003eaddField(\"vector\", Milvus\\DataType::FLOAT_VECTOR, dim: 5)\n        -\u003eaddField(\"text\", Milvus\\DataType::VARCHAR, max_length: 1000, nullable: true)\n        -\u003eaddField(\"metadata\", Milvus\\DataType::JSON, nullable: true),\n    index_params: $client-\u003eprepareIndexParams()\n        -\u003eaddIndex(\n            field_name: \"vector\",\n            index_name: \"my_index\",\n            index_type: Milvus\\IndexType::AUTOINDEX,\n            metric_type: Milvus\\MetricType::COSINE\n        ),\n);\n```\n\n### List All Collections\n\n```php\n$collections = $client-\u003elistCollections();\n```\n\n### Describe Collection\n\n```php\n$desc = $client-\u003edescribeCollection(\"test_collection\");\n```\n\n### Drop Collection\n\n```php\n$client-\u003edropCollection(\"test_collection\");\n```\n\n### Load/Release Collection\n\n```php\n$client-\u003eloadCollection(\"test_collection\");\n$client-\u003ereleaseCollection(\"test_collection\");\n```\n\n### Rename Collection\n\n```php\n$client-\u003erenameCollection(\"old_name\", \"new_name\");\n```\n\n---\n\n## Vector Data Operations\n\n### Insert Data\n\n```php\n$entities = [\n    [\"id\" =\u003e 1, \"vector\" =\u003e [1.0, 2.0, 3.0, 4.0, 5.0]],\n    [\"id\" =\u003e 2, \"vector\" =\u003e [2.0, 2.0, 3.0, 4.0, 5.0]],\n];\n$client-\u003einsert(\"test_collection\", $entities);\n```\n\n### Upsert Data\n\n```php\n$client-\u003eupsert(\"test_collection\", $entities);\n```\n\n### Query Data\n\n```php\n$result = $client-\u003equery(\"test_collection\", \"id in [1,2]\");\n```\n\n### Delete Data\n\n```php\n$client-\u003edelete(\"test_collection\", \"id in [1]\");\n```\n\n### Vector Search\n\n```php\n$result = $client-\u003esearch(\n    collection_name: \"test_collection\",\n    data: [[1.0, 2.0, 3.0, 4.0, 5.0]],\n    anns_field: \"vector\",\n    limit: 10,\n    output_fields: [\"id\", \"vector\"]\n); \n```\n\n---\n\n## Index Operations\n\n### Create Index\n\n```php\n$indexParams = $client-\u003eprepareIndexParams();\n$indexParams-\u003eaddIndex(\n    field_name: \"vector\",\n    index_name: \"my_index\",\n    index_type: Milvus\\IndexType::AUTOINDEX,\n    metric_type: Milvus\\MetricType::COSINE\n);\n$client-\u003ecreateIndex(\"test_collection\", $indexParams);\n```\n\n### List Indexes\n\n```php\n$indexes = $client-\u003elistIndexes(\"test_collection\");\n```\n\n---\n\n## Users \u0026 Privileges\n\n### List Users\n\n```php\n$users = $client-\u003elistUsers();\n```\n\n### Create User\n\n```php\n$client-\u003ecreateUser(\"test_user\", \"password\");\n```\n\n### Describe User\n\n```php\n$userInfo = $client-\u003edescribeUser(\"test_user\");\n```\n\n### Drop User\n\n```php\n$client-\u003edropUser(\"test_user\");\n```\n\n### Update Password\n\n```php\n$client-\u003eupdatePassword(\"test_user\", \"old_password\", \"new_password\");\n```\n\n---\n\n## Roles \u0026 Privileges\n\n### List Roles\n\n```php\n$roles = $client-\u003elistRoles();\n```\n\n### Create Role\n\n```php\n$client-\u003ecreateRole(\"admin\");\n```\n\n### Describe Role\n\n```php\n$roleInfo = $client-\u003edescribeRole(\"admin\");\n```\n\n### Drop Role\n\n```php\n$client-\u003edropRole(\"admin\");\n```\n\n### Grant Privilege to Role\n\n```php\n$client-\u003egrantPrivilege(\"admin\", \"Collection\", \"Insert\", \"test_collection\");\n```\n\n---\n\n## Advanced\n\n### Hybrid Search\n\n```php\n$result = $client-\u003ehybridSearch(\n    collection_name: \"test_collection\",\n    search: [\n        new HybridSearchRequest(\n            data: [[0.1, 0.2, 0.3, 0.4, 0.5]],\n            anns_field: \"vector\",\n            limit: 10,\n            param: []\n        ),\n    ],\n    ranker: new Milvus\\RRFRanker(10),\n    output_fields: [\"id\", \"vector\"]\n);\n```\n\n---\n\n## Reference\n\n- [Milvus Documentation](https://milvus.io/docs)\n- [mathsgod/milvus-client-php on GitHub](https://github.com/mathsgod/milvus-client-php)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathsgod%2Fmilvus-client-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathsgod%2Fmilvus-client-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathsgod%2Fmilvus-client-php/lists"}