yuancode / laravel-zkconfig
laravel-zkconfig is a laravel configuration management tool
v1.0.1
2020-10-17 03:13 UTC
Requires
- php: ^7.2
- illuminate/console: ^5.5|^6.0|^7.0
- illuminate/container: ^5.5|^6.0|^7.0
- illuminate/contracts: ^5.5|^6.0|^7.0
Requires (Dev)
- laravel/framework: ^5.5|^6.0|^7.0
- laravel/lumen-framework: ^5.5|^6.0|^7.0
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