2017 © Pedro Peláez
 

library apollo-config

image

totoro/apollo-config

  • Tuesday, July 3, 2018
  • by yangjiekang
  • Repository
  • 2 Watchers
  • 9 Stars
  • 24 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 12 Versions
  • 118 % Grown

The README.md

Apollo config manage

  • 方便程序快速获取配置参数
  • 支持redisSHMfile 存储方式
  • SHM 只支持linux下使用
  • Laravel 5.5+

Install

composer require totoro/apollo-config

In Laravel

  • config/app.php
'providers' => [
    ...
    ...
    Totoro\Apollo\ApolloServiceProvider::class,
]

In Lumen

  • bootstrap/app.php
$app->configure('apollo');
$app->register(Totoro\Apollo\ApolloServiceProvider::class);

Usage

//值是否存在
app('apollo')->has($key)

//获取某个值
app('apollo')->get($key)

//获取所有值
app('apollo')->all()

重要说明

APOLLO_DRIVERfile 时只要很简单的配置就行, (*1)

Configuration

  • 执行 php artisan apollo:publish-config 将配置文件发布到 (config/apollo.php)

APOLLO_DRIVER设置为 redis 或者 shm

  • 配置文件根据部署的参数设置好
  • 执行 php artisan apollo:publish-consul 将注册中心的服务地址发布到存储库中
  • 执行 php artisan apollo:publish-component 将配置中心参数发布到存储库中
  • 可以执行 php artisan apollo:clear-apollo 清空当前存储库

Cron

app/Console/Kerner.php中加上定时任务调用, (*2)

protected $commands = [
    ...
    ...
    PublishConsulCommand::class,
    PublishComponentCommand::class
];

protected function schedule(Schedule $schedule)
{
    ...
    ...

    //更新注册中心服务地址
    $schedule->command(PublishConsulCommand::class)->everyMinute();
    //更新配置中心单当前服务参数
    $schedule->command(PublishComponentCommand::class)->everyMinute();
 }
  • 启动调度器
* * * * * php /your-project-path/laravel/artisan schedule:run >> /dev/null 2>&1 

APOLLO_DRIVER设置为 file

  • .env 中设置配置文件的路径,默认 /etc/xultra/php_conf,当然也可以只直接在config/apollo.php中设置
APOLLO_DRIVER=file
APOLLO_CONF=/etc/xultra/php_conf
  • 在配置文件 /etc/xultra/php_conf 中设置参数
xu-billing=http://127.0.0.1:1000
xu-audit=http://127.0.0.1000

The Versions

03/07 2018

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

by Avatar yangjiekang

03/07 2018

1.0.6

1.0.6.0

  Sources   Download

MIT

The Requires

 

by Avatar yangjiekang

22/06 2018

1.0.5

1.0.5.0

  Sources   Download

MIT

The Requires

 

by Avatar yangjiekang

15/06 2018

1.0.4

1.0.4.0

  Sources   Download

MIT

The Requires

 

by Avatar yangjiekang

04/06 2018

1.0.3

1.0.3.0

  Sources   Download

MIT

The Requires

 

by Avatar yangjiekang

04/06 2018

1.0.2

1.0.2.0

  Sources   Download

MIT

The Requires

 

by Avatar yangjiekang

01/06 2018

1.0.1

1.0.1.0

  Sources   Download

MIT

The Requires

 

by Avatar yangjiekang

17/05 2018

0.1.0

0.1.0.0

  Sources   Download

MIT

The Requires

 

by Avatar yangjiekang

17/05 2018

1.0.0

1.0.0.0

  Sources   Download

MIT

The Requires

 

by Avatar yangjiekang

17/05 2018

0.0.2

0.0.2.0

  Sources   Download

MIT

The Requires

 

by Avatar yangjiekang

17/05 2018

0.0.1

0.0.1.0

  Sources   Download

MIT

The Requires

 

by Avatar yangjiekang

28/04 2018

0.0.3

0.0.3.0

apollo config test

  Sources   Download

MIT

The Requires

 

by Avatar yangjiekang