1. Go to this page and download the library: Download iprog/apollo-php 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/ */
iprog / apollo-php example snippets
$config = new ApolloPhp\Popo\Config\ApolloHttpClientConfig();
$config->setApolloServerUrl("http://172.17.18.211:3880")
->setApolloAppId("php-unit-test-case")
->setApolloCluster("DEV");
$apolloRedisParam = new ApolloPhp\Popo\ApolloPullParam('redis');
$apolloRedisParam->setClientIp('127.0.0.1');
$apolloRedisParam->setReleaseKey('');
$apolloMysqlParam = new ApolloPhp\Popo\ApolloPullParam('mysql');
$apolloMysqlParam->setClientIp('127.0.0.1');
$apolloMysqlParam->setReleaseKey('');
$apolloPullParams = [$apolloRedisParam, $apolloMysqlParam];
$client = new ApolloPhp\Api\Impl\ApolloHttpClient($config);
$apolloConfigResult = $client->pullConfigs($apolloPullParams);
// 这里会将拉取的配置保存在php对应的配置目录里面
foreach ($apolloConfigResult as $result) {
$apolloConfig = new ApolloPhp\Config\Impl\ApolloConfig('D://config');
$apolloConfig->parseConfig($result);
}