okami-chen/yaml-config

yaml config

Downloads

3

Stars

0

Version

1.0.6

TableShard

config.yml文件内容

local:
    mysql:
        host: 127.0.0.1
        port: 3306
dev:
    mysql:
        host: 127.0.0.1
        port: 3306
qa:
    mysql:
        host: 127.0.0.1
        port: 3306
pre:
    mysql:
        host: 127.0.0.1
        port: 3306
gr:
    mysql:
        host: 127.0.0.1
        port: 3306
yc:
    mysql:
        host: 127.0.0.1
        port: 3306
production:
    mysql:
        host: 127.0.0.1
        port: 3306

读取

<?php
$file   = 'config.yml';
$data   = Yaml::load($file);

写入

<?php
$file   = 'config.yml';
$data   = Yaml::load($file);
$data['mysql']['port'] = 3307;
Yaml::save($file,$data);

config.yml变化后的内容

local:
    mysql:
        host: 127.0.0.1
        port: 3307
dev:
    mysql:
        host: 127.0.0.1
        port: 3306
qa:
    mysql:
        host: 127.0.0.1
        port: 3306
pre:
    mysql:
        host: 127.0.0.1
        port: 3306
gr:
    mysql:
        host: 127.0.0.1
        port: 3306
yc:
    mysql:
        host: 127.0.0.1
        port: 3306
production:
    mysql:
        host: 127.0.0.1
        port: 3306
OkamiChen

Author

OkamiChen