Download the PHP package ssh/nacos-sdk-php without Composer

On this page you can find all versions of the php package ssh/nacos-sdk-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package nacos-sdk-php

Nacos SDK for PHP

适用于 Nacos 2.x / 3.x 的 PHP SDK,提供服务配置管理、服务发现、服务调用等完整能力。

特性

安装

系统要求

依赖 最低版本 说明
PHP >= 8.0
guzzlehttp/guzzle ^6.0 || ^7.0 HTTP 客户端
psr/log ^1.0 || ^2.0 || ^3.0 日志接口
symfony/options-resolver ^5.0 || ^6.0 参数解析

快速开始

创建客户端

用户名密码认证(自建 Nacos)

AK/SK 认证(阿里云 MSE 等)

自定义命名空间

配置管理

使用示例:

服务发现

使用示例:

服务调用

使用示例:

响应结构:

Feign 声明式客户端

使用示例:

领域模型

Webman 集成

本 SDK 内置 Webman 插件支持,安装到 Webman 项目时自动创建配置文件。

安装

安装后自动创建 config/plugin/nacos/ 目录,包含:

环境变量配置(.env)

在控制器中使用

配置就绪中间件(可选)

在 config/middleware.php 中添加:

当 Nacos 配置未同步完成时返回 503,避免使用默认配置处理请求。

手动创建配置(如自动安装未触发)

项目结构

认证方式

方式 配置 适用场景
用户名密码 构造函数传入 username / password 自建 Nacos 集群
AK/SK 构造函数传入 accessKey / secretKey 阿里云 MSE 等托管服务

两种方式可以同时配置,SDK 会按需使用。用户名密码认证会自动登录获取 accessToken 并定期刷新。

注意事项

  1. 命名空间 public:Nacos 的 public 命名空间实际 ID 为空字符串,SDK 内部自动处理,用户传入 'public' 即可。

  2. JSON 格式配置:getConfig() 使用原始响应体获取配置内容,不会将 JSON 格式的配置误解析为数组。

  3. 持久化实例:Nacos standalone 模式下持久化实例可能因 Raft 一致性限制返回 500 错误,这是 Nacos 服务端已知问题,集群模式不受影响。

  4. 服务调用缓存:ServiceInvoker 默认缓存健康实例 30 秒,可通过 clearCache() 手动清除。

许可证

MIT License


All versions of nacos-sdk-php with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
guzzlehttp/guzzle Version ^6.0 || ^7.0
psr/log Version ^1.0 || ^2.0 || ^3.0
symfony/options-resolver Version ^5.0 || ^6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ssh/nacos-sdk-php contains the following files

Loading the files please wait ...