PHP code example of xin / setting

1. Go to this page and download the library: Download xin/setting 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/ */

    

xin / setting example snippets



/** @var \Xin\Setting\SettingManager $setting */
$setting = app('setting');

// 加载配置
$data = $setting->load();
var_dump($data);

// 加载配置到系统配置中
$setting->loadToSystemConfig();

// 添加配置
$setting->upsert('hello','world');

// 获取配置
$value = $setting->find('hello');
var_dump($value);



use Xin\Setting\Facades\Setting;
// 加载配置
$data = Setting::load();
var_dump($data);

// 加载配置到系统配置中
Setting::loadToSystemConfig();

// 添加配置
Setting::create('web_title',[
    'title'=>'站点标题',
    'value'=>'PHP is very good language!',
    'type'=>'string',
]);
Setting::update('web_title',[
    'title'=>'站点标题',
    'value'=>'PHP is best language!',
]);

// 获取配置
$value = Setting::get('web_title');
var_dump($value);