Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
actors315 edited this page May 7, 2020 · 6 revisions

注:客户端只支持 properties, 配置文件用 ini 文件保存。

安装

composer require twinkle/apollo-client

配置

根据使用场景选择对应的配置方式

-- fpm
env[ENV] = dev # 这是环境
env[APOLLO_SERVER]=http://127.0.0.1:8080 # 这里是服务端地址
env[APOLLO_CONF_DIR]=/data/www/apollo-config # 这里是配置文件保存路径
service php-fpm restart
 
-- apache
SetEnv ENV dev
SetEnv APOLLO_SERVER http://127.0.0.1:8080
SetEnv APOLLO_CONF_DIR /data/www/apollo-config
service httpd restart
 
-- cli
vi /etc/profile
export ENV=dev
export APOLLO_SERVER=http://127.0.0.1:8080
export APOLLO_CONF_DIR=/data/www/apollo-config
source /etc/profile

此外也可以用过 define 定义如上同名常量来设定对应值

启动客户端

{DIR}/vendor/bin/apollo --application=test-app --namespace=application,switch &

--application 指定应用名
--namespace 指定命名空间
--configDir 配置文件保存路径,如果指定了这个参数优先用它。不指定取上面的配置

获取配置

$config = new \twinkle\apollo\Config(getenv('APOLLO_CONF_DIR'), $appName, $application);
$dbHost = $config['DB_HOST'];

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /