PHPackages                             tals/nacos-sdk-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. [API Development](/categories/api)
4. /
5. tals/nacos-sdk-php

ActiveLibrary[API Development](/categories/api)

tals/nacos-sdk-php
==================

PHP SDK For Nacos

v0.0.3(4y ago)121MITPHPPHP &gt;=7.1.0

Since Aug 11Pushed 4y ago1 watchersCompare

[ Source](https://github.com.cnpmjs.org/HowlsCastle/Nacos-sdk.git)[ Packagist](https://packagist.org/packages/tals/nacos-sdk-php)[ RSS](/packages/tals-nacos-sdk-php/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (3)Versions (4)Used By (0)

Nacos-Sdk-PHP
=============

[](#nacos-sdk-php)

![license](https://camo.githubusercontent.com/01dc134d6da3895cd6eefe1d56c34de8cbe95bf3a7473f569d32dcf83676ac0b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f54696e7977616e2f6e61636f732d73646b2d706870)[![996.icu](https://camo.githubusercontent.com/ac8f294a80f65338db545230f1a881b9a382204a1f187c6ff40ee679d42d40ca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c696e6b2d3939362e6963752d7265642e737667)](https://996.icu)![Build status](https://github.com/Tinywan/dnmp/workflows/CI/badge.svg)![nacos-sdk-php](https://camo.githubusercontent.com/e63901d96a1faac8b8ebf6f7f78f8def5614d5b210a16c60d98275e88d91ae5d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f74696e7977616e2f6e61636f732d73646b2d7068703f696e636c7564655f70726572656c6561736573)![nacos-sdk-php](https://camo.githubusercontent.com/c27a457659b89ee4f1f80f7995c559dd37f2051bde7167ad25791e5c5c92cc8e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6275696c642d70617373696e672d627269676874677265656e2e737667)![nacos-sdk-php](https://camo.githubusercontent.com/4ffc06a062a1838f4d5e0639b198b3a29832a443a70a0f58f7f9e65a4f6cb4e3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f74696e7977616e2f6e61636f732d73646b2d706870)![nacos-sdk-php](https://camo.githubusercontent.com/146bba89b463d27efc916b88ba84f09495901a54c4103dd903e89a419df715a5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f74696e7977616e2f6e61636f732d73646b2d7068702f6d61696e)![nacos-sdk-php](https://camo.githubusercontent.com/5937ba93718324d9d6358f9cc7688dfadfa0fa02de7087f3bfcf4c3802a388d1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f74696e7977616e2f6e61636f732d73646b2d7068703f636f6c6f723d666636396234)

Nacos-Sdk-PHP
-------------

[](#nacos-sdk-php-1)

Nacos-Sdk-PHP for PHP client allows you to access Nacos OpenAPI. [Open API Guide](https://nacos.io/en-us/docs/open-api.html)

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

[](#requirements)

- PHP ^7.0

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

[](#installation)

```
composer require tinywan/nacos-sdk-php
```

Getting Started
---------------

[](#getting-started)

```
use Nacos\NacosClient;

$client = new NacosClient('localhost', 8848);

$dataId = 'database.php';
$group = 'DEFAULT_GROUP';
$result = $client->getConfig($dataId, $group);
```

Use Namespace
-------------

[](#use-namespace)

```
use Nacos\NacosClient;

$dataId = 'database.php';
$group = 'DEFAULT_GROUP';
$namespace = 'c78ce19d-82d1-456a-8552-9a0db6c11d01';

$client = new NacosClient('localhost', 8848);
$client->setNamespace($namespace);
$result = $client->getConfig($dataId, $group);
```

Listener Config
---------------

[](#listener-config)

```
use Nacos\NacosClient;
use Nacos\Models\Config;

$dataId = 'database.php';
$group = 'DEFAULT_GROUP';
$namespace = 'c78ce19d-82d1-456a-8552-9a0db6c11d01';

$client = new NacosClient('localhost', 8848);
$client->setNamespace($namespace);
$client->setTimeout(3);
$content = $client->getConfig($dataId, $group);
$contentMd5 = md5($content);

$cache = new Config();
$cache->dataId = $dataId;
$cache->group = $group;
$cache->namespace = $namespace;
$cache->contentMd5 = $contentMd5;
$result = $client->listenConfig([$cache]);
if(!empty($result)) {
    $updateContent = $client->getConfig($dataId, $group);
    echo '[x] update content : ' . $updateContent, "\n";
} else {
    echo '[x] this is not update ', "\n";
}
```

Register an instance to the service
-----------------------------------

[](#register-an-instance-to-the-service)

```
use Nacos\NacosClient;
use Nacos\Models\Config;

$client = new NacosClient('localhost', 8848);

$serviceName  = 'NacosTaskService';
$instance = new ServiceInstance();
$instance->serviceName = $serviceName;
$instance->ip = '127.0.0.1';
$instance->port = 80;
$instance->healthy = true;
$instance->ephemeral = false;

$isSuccess = $client->createInstance($instance);
if(true === $isSuccess) {
    echo '[x] create service instance success ', "\n";
} else {
    echo '[x] create service instance fail ', "\n";
}
```

[![nacaos-regiter-service.png](./img/nacaos-regiter-service.png)](./img/nacaos-regiter-service.png)

API
---

[](#api)

### Request Options

[](#request-options)

- setNamespace
    - string $namespace
- setTimeout
    - int $timeout

### Config API

[](#config-api)

- getConfig
    - string $dataId
    - string $group = NacosClient::DEFAULT\_GROUP
- publishConfig
    - string $dataId
    - string $group
    - $content
- removeConfig
    - string $dataId
    - string $group = NacosClient::DEFAULT\_GROUP
- listenConfig
    - array $configs
    - int $timeout = 30

### Naming API

[](#naming-api)

- createInstance
    - ServiceInstance $instance
- deleteInstance
    - string $serviceName
    - string $ip
    - int $port
    - string $clusterName = null
    - string $namespaceId = null
- updateInstance
    - ServiceInstance $instance
- getInstanceList
    - string $serviceName
    - string $namespaceId = null
    - array $clusters = \[\]
    - bool $healthyOnly = false
- getInstance
    - string $serviceName
    - string $ip
    - int $port
    - string $namespaceId = null
    - string $cluster = null
    - bool $healthyOnly = false
- sendInstanceBeat
    - string $serviceName
    - BeatInfo $beat

PHPUnit Test
------------

[](#phpunit-test)

NacosClientTest

```
./vendor/bin/phpunit --bootstrap src/Nacos/NacosClient.php tests/NacosClientTest.php

```

- phpunit 调用命令行测试PHPUnit
- --bootstrap src/Nacos/NacosClient.php 指示PHPUnit命令行测试在测试之前执行 include src/Nacos/NacosClient.php
- tests/NacosClientTest.php 指示PHPUnit命令行测试要执行的测试 NacosClientTest 类声明在 tests/NacosClientTest.php
-

NacosConfig

```
./vendor/bin/phpunit --bootstrap src/Nacos/NacosConfig.php tests/NacosConfigTest.php

```

NacosNaming

```
./vendor/bin/phpunit --bootstrap src/Nacos/NacosNaming.php tests/NacosNamingTest.php

```

Other
-----

[](#other)

Docker Composer

```
docker run --rm --interactive --tty -v e:/GitHub/nacos-sdk-php:/app composer:1.10.16 install --ignore-platform-reqs

```

Git Tag

```
git push origin v0.0.42
// or push all
git push origin --tags

```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

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

Total

3

Last Release

1730d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0aeecc16e6365c8a624766802a6a46775a19e1fd7a76e3ca0dd7b15e1ed73334?d=identicon)[HowlsCastle](/maintainers/HowlsCastle)

---

Top Contributors

[![HowlsCastle](https://avatars.githubusercontent.com/u/5523569?v=4)](https://github.com/HowlsCastle "HowlsCastle (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

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