PHP code example of yuancode / laravel-zkconfig

1. Go to this page and download the library: Download yuancode/laravel-zkconfig library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yuancode / laravel-zkconfig example snippets


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

$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
bash
php artisan vendor:publish --provider="Yuancode\ZkConfig\ZkConfigServiceProvider" --tag=config
bash
php artisan zkconfig:server cache
bash
php artisan zkconfig:server cache
bash
php artisan zkconfig:server start