dreamcat / apollo-php
apollo配置中心php客户端
v1.0.2
2020-01-18 14:22 UTC
Requires
- php: >=7.2
- ext-json: *
- ext-pcntl: *
- ext-posix: *
- dreamcat/enhance_http_client: ^1.0
- dreamcat/utils: ^2
- psr/log: ^1.1
Requires (Dev)
- phpunit/phpunit: ^8
This package is auto-updated.
Last update: 2024-11-19 01:14:02 UTC
README
介绍
安装教程
composer require dreamcat/apollo-php
使用说明
fpm 示例代码
<?php
use Dreamcat\ApolloPhp\Api\Impl\ApolloServer;
use Dreamcat\ApolloPhp\Impl\ApolloReadProcess;
use Dreamcat\ApolloPhp\Impl\Saver\SingleSaver;
use Psr\Log\NullLogger;
# 名空间对应的保存文件
$map = [
"application" => "config.php",
"script" => "script.php",
];
$process = new ApolloReadProcess("apollo.cae");
$process->setLogger(new NullLogger())
->setApolloServer(new ApolloServer("http://config.url.com"))
->setConfigSaver(new SingleSaver($map))
->readConfig("appid", "cluserName", array_keys($map));
swoole 示例代码
<?php
use Dreamcat\ApolloPhp\Api\Impl\ApolloServer;
use Dreamcat\ApolloPhp\Impl\ApolloReadProcess;
use Dreamcat\ApolloPhp\Impl\Saver\SingleSaver;
use Dreamcat\ApolloPhp\Impl\Saver\SwooleSaver;
use Psr\Log\NullLogger;
# 名空间对应的保存文件
$map = [
"application" => "config.php",
"script" => "script.php",
];
$process = new ApolloReadProcess("apollo.cae");
$process->setLogger(new NullLogger())
->setApolloServer(new ApolloServer("http://config.url.com"))
->setConfigSaver(new SwooleSaver(new SingleSaver($map), "swoole_server.pid"))
->readConfig("appid", "cluserName", array_keys($map));