yuancode/laravel-zkconfig

laravel-zkconfig is a laravel configuration management tool

v1.0.1 2020-10-17 03:13 UTC

This package is auto-updated.

Last update: 2024-04-17 12:23:16 UTC


README

简体中文

laravel-zkconfig is a laravel configuration management tool. You can save some configuration information in zookeeper.

Instructions

Installation

composer require 'yuancode/laravel-zkconfig'

Publish configuration files

php artisan vendor:publish --provider="Yuancode\ZkConfig\ZkConfigServiceProvider" --tag=config

Add zk configuration

create /test/zkconfig '{"app.name": "test"}'

Modify the code

Modify the bootstrap/app.php file and add the following code under $app:

$app->afterBootstrapping(\Illuminate\Foundation\Bootstrap\LoadConfiguration::class, function ($app) {
     $zk = new \Yuancode\ZkConfig\Zk($app);
     $zk->loadZkConfig();
});

lumen

$app = new Laravel\Lumen\Application(
    dirname(__DIR__)
);

$zk = new \Yuancode\ZkConfig\Zk($app);
$zk->setHost('127.0.0.1:2181')    //zookeeper host
->setPath('/app/zkconfig/')       //config root path
->setCachePath(storage_path('zkconfig/config.json')) //config cache path
->setMode(\Yuancode\ZkConfig\Config::MODE_ENV)  //replace env variable
->setValType(\Yuancode\ZkConfig\Zk::VALUE_TYPE_KEY) //key,value mode
->loadZkConfig();  //load config

Available commands

Cache zk

php artisan zkconfig:server cache

Clean up the zk cache

php artisan zkconfig:server cache

Automatically update the zk cache

php artisan zkconfig:server start