easyswoole / apollo-config
easyswoole component
Installs: 1 179
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- php: >=7.1.0
- easyswoole/config: ^1.0
- easyswoole/http-client: ^1.3
- easyswoole/spl: ^1.2
Requires (Dev)
- easyswoole/phpunit: ^1.0
- easyswoole/swoole-ide-helper: ^1.2
This package is auto-updated.
Last update: 2024-12-15 18:25:07 UTC
README
Easyswoole Apollo 配置中心
安装
composer require easyswoole/apollo-config
示例代码
use EasySwoole\ApolloConfig\Server;
use EasySwoole\ApolloConfig\Apollo;
go(function (){
$server = new Server([
'server'=>'http://106.12.25.204:8080',
'appId'=>'easyswoole'
]);
$config = new Apollo();
/*
* 设置当前客户端所处的数据中心名字,可选
*/
$config->getClient()->setDataCenter('testDataCenter');
$config->setServer($server);
/*
* 配置需要同步的配置项namespace
*/
$config->setNameSpace([
'mysql'
]);
/*
* 进行配置项同步
*/
$config->sync();
var_dump($config->getConf('mysql'));
var_dump($config->getConf('mysql.db'));
var_dump($config->getReleaseKey('mysql'));
});
自己自己添加定时器进行定时同步