phpone/yii2-apollo

yii2-apollo client

Installs: 14

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 0

Open Issues: 0

Type:yii2-extension

0.0.1 2019-08-14 10:42 UTC

This package is auto-updated.

Last update: 2024-05-15 18:36:07 UTC


README

Instruction

  • install
composer require phpone/yii2-apollo
  • change .env file
APP_ID=1
CLUSTER=default
APOLLO_NAMESPACES="application,hogwarts.common_snape_config"
APOLLO_COMMON_NAMESPACE="hogwarts.common_snape_config"
APOLLO_CONFIG_SERVER=127.0.0.1
  • add configuration in console.php & web.php
[
    'aliases' => [
        '@storagePath' => '@app/storage',
        '@apolloPath' => '@storagePath/apollo'
    ]
];
  • add configuration in console.php
[
    'controllerMap' => [
        'apollo.start-agent' => [
            'class' => 'Wby\ApolloYii\commands\ApolloClientController',
            'namespaces' => explode(',', getenv('APOLLO_NAMESPACES', 'application')),
            'cluster' => getenv('APOLLO_CLUSTER', 'default'),
            'save_dir' => '@apolloPath',
            'config_server' => getenv('APOLLO_CONFIG_SERVER', 'http://192.168.100.184:8090'),
            'app_id' => getenv('APP_ID'),
            'timeout_interval' => 70
        ]
    ]
];
    

use

  • exec ./yii apollo.start-agent , if you want to keep the script run in daemon can see http://supervisord.org/
  • how get config
$namespace = 'application';
$key = 'host';
$host = Apollo::connect($namespace)->get($key);