beicroon/apollo-php-client

The [ctripcorp/apollo] client for php.

This package's canonical repository appears to be gone and the package has been frozen as a result.

dev-master 2020-09-02 09:25 UTC

This package is auto-updated.

Last update: 2021-06-30 11:10:20 UTC


README

安装

composer require beicroon/apollo-php-client

使用

use Beicroon\ApolloClient;
use GuzzleHttp\Exception\GuzzleException;

$server = 'http://127.0.0.1:8080';

$appId = 'your-app-id';

$namespaces = ['common', 'application'];

$client = ApolloClient::make($server, $appId, $namespaces)
    ->setCluster('default')
    ->setClientIp('127.0.0.1');

$env = __DIR__.DIRECTORY_SEPARATOR.'.env';

while (true) {
    try {
        if ($client->listen($env)) {
            // success
        }
    } catch (GuzzleException $exception) {
        // http error
    }

    sleep(60);
}