Download the PHP package apollo-sdk/clientd without Composer

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

Ctrip Apollo PHP Client

说明

这个仓库基于apollo-sdk/config实现了常驻的阿波罗客户端,从指定阿波罗配置中心实时拉取应用的配置到本地, 通过json格式化之后缓存在本地目录

特性

安装(提供两种方式)

第一种基于git仓库运行

第二种基于phar包运行

启动(仅支持cli模式)

参数说明

cli启动参数

参数 说明 默认值
--server Apollo配置中心服务的地址
--conf-portal 读取额外参数配置的入口
-h 显示帮助信息
--help 同-h
--q 开启静默模式,屏蔽运行时日志
--quiet 同-q
--secret 访问密钥
--cluster-name 集群名 default
--skip-check-server 是否跳过启动时检查Apollo配置中心是否合法的检查
--conf-portal-separator conf-portal参数的分隔符 /

关于--conf-portal参数说明

--conf-portal参数用于将一些额外的参数(例如应用id,namespace信息等)保存在阿波罗配置中心, 这样就不必在apollo-clientd启动时写死了,这也减少了apollo-clientd启动参数个数, 程序会在启动的时候到这配置入口去读取配置,这个参数格式为appid/namespace/key,以下图作为例子说明

Screenshot

上图的参数为--conf-portal=apollo-sdk-clientd/hello_world/world

额外参数配置(json格式)

如果不在app_namespace_list里面配置应用的namespace列表(例如应用demo2和demo3), 程序启动的时候会尝试通过以app_namespace_list_portal参数为入口读取namespace列表,格式如下: Screenshot

程序会通过这个namespace读取当前应用下的namespace列表

完整示意图如下(只需要把当前应用下的namespace都配置在入口即可):

Screenshot

业务端读取配置

业务上需要读取阿波罗配置时,引入apollo-sdk/clientd这个composer包即可,参考以下步骤

代码上引入composer

例子:


<?php
require 'vendor/autoload.php';

$key = 'hello';//namespace下的各业务key
$appId = 'demo';//支持通过全局变量或者环境变量赋值,变量名为:APOLLO_SDK_APPID
$namespaceName = 'test';//支持通过全局变量或者环境变量赋值,变量名为:APOLLO_SDK_NAMESPACE_NAME
$saveConfigDir = '/data/apollo';//支持通过全局变量或者环境变量赋值,变量名为:APOLLO_SDK_SAVE_CONFIG_DIR

//1.传统传参方式
var_dump(\ApolloSdk\Helpers\get_config($key, '', $namespaceName, $appId, $saveConfigDir));

//2.常量配置方式(对于单应用id场景比较适用,不需要每个调用都传递重复的应用id参数和保存配置目录参数)
在框架入口处配置常量,例如laravel框架根目录public/index.php里面配置以下的值
defined('APOLLO_SDK_APPID', $appId);
defined('APOLLO_SDK_SAVE_CONFIG_DIR', $saveConfigDir);
//defined('APOLLO_SDK_NAMESPACE_NAME', $namespaceName);

//然后业务代码就可以不需要传递这些已经定义好的常量了
var_dump(\ApolloSdk\Helpers\get_config($key, '', $namespaceName);

All versions of clientd with dependencies

PHP Build Version
Package Version
Requires apollo-sdk/config Version ^1.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 apollo-sdk/clientd contains the following files

Loading the files please wait ....