PHPackages                             muqiuren/nacos-php - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. muqiuren/nacos-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

muqiuren/nacos-php
==================

nacos的php客户端

v1.1.0(2y ago)1821MITPHPPHP &gt;=7.1CI passing

Since Jul 3Pushed 1y ago1 watchersCompare

[ Source](https://github.com/muqiuren/nacos-php)[ Packagist](https://packagist.org/packages/muqiuren/nacos-php)[ RSS](/packages/muqiuren-nacos-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (2)Versions (12)Used By (0)

Nacos的php客户端库
=============

[](#nacos的php客户端库)

[![PHP Version Require](https://camo.githubusercontent.com/6aa3579f04047e7438e9379bca04794bed30faf81e90be0b3304e0ad307f0624/68747470733a2f2f706f7365722e707567782e6f72672f6d7571697572656e2f6e61636f732d7068702f726571756972652f706870)](https://packagist.org/packages/muqiuren/nacos-php)[![License](https://camo.githubusercontent.com/c08dfb2ff5e46b9d5f8ca57e85b756e0d31d0f9945c875dafa1eda5cced8636b/68747470733a2f2f706f7365722e707567782e6f72672f6d7571697572656e2f6e61636f732d7068702f6c6963656e7365)](https://packagist.org/packages/muqiuren/nacos-php)[![Total Downloads](https://camo.githubusercontent.com/fb593fa9a9466788271d3c7810543b33f4ba1e74d8642dcd4dbc65610b61bb68/68747470733a2f2f706f7365722e707567782e6f72672f6d7571697572656e2f6e61636f732d7068702f646f776e6c6f616473)](https://packagist.org/packages/muqiuren/nacos-php)[![Latest Stable Version](https://camo.githubusercontent.com/a7490efba6070094558dc0cee2739f7d7a2285c2743b76c856456fdc78412681/68747470733a2f2f706f7365722e707567782e6f72672f6d7571697572656e2f6e61636f732d7068702f76)](https://packagist.org/packages/muqiuren/nacos-php)

最近需要用到nacos，项目是php编写的，看了很多开源的轮子，要么不支持username&amp;password模式，要么就是深度集成到框架中，要么就是各种乱七八糟的错误，所以打算自己接入[nacos](https://nacos.io/)。

什么是[Nacos](https://nacos.io/zh-cn/docs/what-is-nacos.html)

Nacos的[open api](https://nacos.io/zh-cn/docs/open-api.html)

### 特点

[](#特点)

1. 简单易用
2. 支持username&amp;password鉴权模式
3. 支持调用所有Nacos Open Api接口
4. 后续积极开发支持

### 安装

[](#安装)

```
composer require muqiuren/nacos-php
```

### 使用

[](#使用)

1. 获取配置

```
use Hatch\Nacos\NacosClient;

$options = [
    // nacos服务端地址
    'host' => '127.0.0.1',
    // nacos服务端端口
    'port' => 8848,
    // 命名空间id
    'namespace_id' => '1e7b3de6-7edb-4329-9184-46582480063b',
    // 配置id
    'data_id' => 'php_env_config',
    // 配置组
    'group' => 'test',
    // nacos用户名
    'username' => 'admin',
    // nacos密码
    'password' => 'admin',
];

$client = new NacosClient($options);
// 获取配置
$conf = $client->configs->get();
var_dump(conf);
```

2. 监听配置

```
use Hatch\Nacos\NacosClient;

$options = [
    // nacos服务端地址
    'host' => '127.0.0.1',
    // nacos服务端端口
    'port' => 8848,
    // 命名空间id
    'namespace_id' => '1e7b3de6-7edb-4329-9184-46582480063b',
    // 配置id
    'data_id' => 'php_env_config',
    // 配置组
    'group' => 'test',
    // nacos用户名
    'username' => 'admin',
    // nacos密码
    'password' => 'admin',
    // 自动保存的文件地址
    'save_config_path' => '.env',
];

$client = new NacosClient($options);
// 启动监听，会阻塞当前进程
$client->configs->listen(function($newMd5) {
    var_dump($newMd5);
});
```

更多示例请看example目录提供的调用示例

### TODO

[](#todo)

- 增强异常处理与容错
- 增强日志输出
- Open Api接口对接
- 提供更多示例
- 接入单元测试

### OpenApi接口支持列表

[](#openapi接口支持列表)

#### 配置中心

[](#配置中心)

- 获取配置
- 监听配置
- 发布配置
- 删除配置
- 查询历史版本
- 查询历史版本详情
- 查询配置上一版本信息

#### 服务发现

[](#服务发现)

- 注册实例
- 注销实例
- 修改实例
- 查询实例列表
- 查询实例详情
- 发送实例心跳
- 创建服务
- 删除服务
- 修改服务
- 查询服务
- 查询服务列表
- 查询系统开关
- 修改系统开关
- 查看系统当前数据指标
- 查看当前集群Server列表
- 查看当前集群leader
- 更新实例的健康状态

#### 命名空间

[](#命名空间)

- 查询命名空间列表
- 创建命名空间
- 修改命名空间
- 删除命名空间

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity45

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 ~19 days

Recently: every ~46 days

Total

11

Last Release

859d ago

Major Versions

v0.4.0-beta → v1.0.02023-07-08

PHP version history (2 changes)v0.1.0-betaPHP &gt;=7.1

v1.0.1PHP ^7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/e0b3449f99e61c506a5c416e64e8612166ce3bcf4058961481bf84ebb16f0892?d=identicon)[hatch](/maintainers/hatch)

---

Top Contributors

[![muqiuren](https://avatars.githubusercontent.com/u/16541671?v=4)](https://github.com/muqiuren "muqiuren (3 commits)")

---

Tags

nacosnacos-phpnacos-sdk-phpphp

### Embed Badge

![Health badge](/badges/muqiuren-nacos-php/health.svg)

```
[![Health](https://phpackages.com/badges/muqiuren-nacos-php/health.svg)](https://phpackages.com/packages/muqiuren-nacos-php)
```

###  Alternatives

[google/cloud-core

Google Cloud PHP shared dependency, providing functionality useful to all components.

343121.4M79](/packages/google-cloud-core)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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