Download the PHP package xiaosongshu/nacos without Composer

On this page you can find all versions of the php package xiaosongshu/nacos. 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

简单的php版本nacos客户端

安装

项目地址

客户端示例

应用举例

注册发布服务,监听配置示例

本项目提供已编写好的服务端Xiaosongshu\Nacos\Server和客户端Xiaosongshu\Nacos\JsonRpcClient

服务端配置文件

其中配置文件config.php,内容如下:

如果需要监听配置,如上面文件的配置application.yaml,假设文件内容如下:

服务端代码

你可以编写一个server.php文件,内容如下

而服务提供者DemoService.php内容如下

服务提供者LoginService.php内容如下:

编写完以上文件后,开启服务,命令如下:

客户端代码

这个时候我们再编写一个客户端client.php,用来测试调用服务。内容如下:

现在需要启动客户端来测试服务是否可用。命令如下:

服务端运行效果

那么服务端测试结果大概效果是这样子的

客户端的效果是这个样子的

服务降级和熔断

系统默认超时率大于等于50%的时候,会对服务进行降级处理,当超时率低于50%的时候会逐步恢复。当服务的错误率高于50%的时候,会对服务进行熔断处理,nacos服务器会移除当前实例,请人工排查并修复问题后重新上架该实例。

一键搭建nacos服务

和常用的框架集成

当你看到这里的时候,需要一些常用框架的基本知识了,此处默认你都已掌握。

thinkphp5.1

首先配置需要的服务,我这里只需要用到服务注册发现模块,那么\config\nacos.php配置如下,

需要注册的服务提供者\app\service\WechatService::class内容如下:

作者将nacos服务放在了命令行中,使用thinkphp的命令行来启动服务,\app\command\NacosServer::class的内容如下:

启动服务端,你需要执行以下命令:

如果是你在linux服务器上,需要无人值守模式,那么执行以下命令

接下来是客户端的调用,你可以在你的任何业务端代码里面(包括但不限于控制器,命令行),代码如下:

接下来你可以启用你的业务代码测试。当然以上代码只是作者的demo,实际上你的项目路径可能不一样,请根据实际情况调整。当前插件可以集成到thinkphp,laravel,yii,webman等等常用的框架,因为用法都一样,这里就不一一列举了。


All versions of nacos with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
ext-json Version *
ext-sockets Version *
ext-curl Version *
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 xiaosongshu/nacos contains the following files

Loading the files please wait ....