PHP code example of easyswoole / apollo-config
1. Go to this page and download the library: Download easyswoole/apollo-config library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
easyswoole / apollo-config example snippets
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'));
});