seffeng/nacos

PHP extension nacos

v0.1.3 2023-08-02 01:37 UTC

This package is auto-updated.

Last update: 2024-12-01 00:12:54 UTC


README

安装

# 安装
$ composer require seffeng/nacos

目录说明

├───src
│   │   Nacos.php
│   ├───Exceptions
│   │       NacosException.php
│   └───Handlers
│           Configs.php
│           Instances.php
│           Log.php
├───tests
│       NacosConfig.php
│       NacosInstance.php

示例

/**
 * Test
 */
class NacosConfig
{
    /**
     * 获取配置
     */
    public function testGet()
    {
        try {
            $conf = $this->getConfig()->getConfig();
            var_dump($conf);
        } catch (\Exception $e) {
            throw $e;
        }
    }

    /**
     * 监听配置
     */
    public function testListener()
    {
        try {
            $conf = $this->getConfig()->listenerConfig();
            var_dump($conf);
        } catch (\Exception $e) {
            throw $e;
        }
    }

    private function getConfig()
    {
        $host = 'http://nacos.io';
        $nacos = new Nacos($host, 'nacos', 'nacos');
        $config = new Configs($nacos, 'test-01');
        return $config;
    }
}

方法

项目依赖

备注

1、更多示例请参考 tests 目录下测试文件;

2、更多文档:nacos.io