All Projects → laruence → Yaconf

laruence / Yaconf

Licence: other
A PHP Persistent Configurations Container

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Yaconf

Awesome Saltstack
🧂 A collaborative curated list of awesome SaltStack resources, tutorials and other salted stuff.
Stars: ✭ 430 (-57.72%)
Mutual labels:  configuration-management
Apollo
Apollo is a reliable configuration management system suitable for microservice configuration management scenarios.
Stars: ✭ 26,052 (+2461.65%)
Mutual labels:  configuration-management
Config Rs
⚙️ Layered configuration system for Rust applications (with strong support for 12-factor applications).
Stars: ✭ 915 (-10.03%)
Mutual labels:  configuration-management
Nacos Spring Boot Project
Nacos ECO Project for Spring Boot
Stars: ✭ 508 (-50.05%)
Mutual labels:  configuration-management
Ini Parser
Read/Write an INI file the easy way!
Stars: ✭ 643 (-36.77%)
Mutual labels:  configuration-management
Conf
Simple config handling for your app or module
Stars: ✭ 707 (-30.48%)
Mutual labels:  configuration-management
Python Dotenv
Get and set values in your .env file in local and production servers. 🎉
Stars: ✭ 4,533 (+345.72%)
Mutual labels:  configuration-management
Configuration
Library for setting values to structs' fields from env, flags, files or default tag
Stars: ✭ 37 (-96.36%)
Mutual labels:  configuration-management
Spring Cloud Config Admin
Spring Cloud Config的综合管理后台(简称:SCCA)
Stars: ✭ 645 (-36.58%)
Mutual labels:  configuration-management
Strictyaml
Type-safe YAML parser and validator.
Stars: ✭ 836 (-17.8%)
Mutual labels:  configuration-management
Aconfmgr
A configuration manager for Arch Linux
Stars: ✭ 576 (-43.36%)
Mutual labels:  configuration-management
Ohai
Ohai profiles your system and emits JSON
Stars: ✭ 641 (-36.97%)
Mutual labels:  configuration-management
Opsmop
DISCONTINUED: permanent copy of fork lives at github.com/mpdehaan/opsmop
Stars: ✭ 725 (-28.71%)
Mutual labels:  configuration-management
Koanf
Light weight, extensible configuration management library for Go. Built in support for JSON, TOML, YAML, env, command line, file, S3 etc. Alternative to viper.
Stars: ✭ 450 (-55.75%)
Mutual labels:  configuration-management
Bash Toolkit
Este proyecto esá destinado a ayudar a los sysadmin
Stars: ✭ 13 (-98.72%)
Mutual labels:  configuration-management
Agileconfig
基于.NET Core开发的轻量级分布式配置中心 / .NET Core light configuration server
Stars: ✭ 403 (-60.37%)
Mutual labels:  configuration-management
Yacs
YACS -- Yet Another Configuration System
Stars: ✭ 705 (-30.68%)
Mutual labels:  configuration-management
Chef Plugin
This is jenkins plugin to run chef-client on remote host
Stars: ✭ 38 (-96.26%)
Mutual labels:  configuration-management
System
Development repository for the "system" Chef cookbook
Stars: ✭ 21 (-97.94%)
Mutual labels:  configuration-management
Node Config Loader
Scan directories and loads config json and yaml files
Stars: ✭ 5 (-99.51%)
Mutual labels:  configuration-management

Yaconf - Yet Another Configurations Container

Build Status Build status Build Status

A PHP Persistent Configurations Container

Requirement

  • PHP 7+

Introduction

Yaconf is a configurations container, it parses ini files, store the result in PHP when PHP is started, configurations live in the whole PHP lifecycle, which makes it very fast.

Features

  • Fast, Light
  • Zero-copy while accesses configurations
  • Support sections, sections inheritance
  • Configurations reload automatically after changed

Install

Compile Yaconf in Linux

Yaconf is an PECL extension, thus you can simply install it by:

$pecl install yaconf

Or you can compile it by your self:

$ /path/to/php7/bin/phpize
$ ./configure --with-php-config=/path/to/php7/bin/php-config
$ make && make install

Runtime configuration

  • yaconf.directory
  Path to directory which all ini configuration files are placed in
  • yaconf.check_delay
  In which interval Yaconf will detect ini file's change(by directory's mtime),
  if it is set to zero, you have to restart php to reloading configurations.

APIs

mixed Yaconf::get(string $name, mixed $default = NULL)
bool  Yaconf::has(string $name)

Example

Directory

Assuming we place all configurations files in /tmp/yaconf/, thus we added this into php.ini

yaconf.directory=/tmp/yaconf

INI Files

Assuming there are two files in /tmp/yaconf

foo.ini

name="yaconf"                  ;string
year=2015                      ;number
features[]="fast"              ;map
features.1="light"
features.plus="zero-copy"
features.constant=PHP_VERSION  ;PHP constants
features.env=${HOME}           ;Enviorment variables

and bar.ini

[base]
parent="yaconf"
children="NULL"

[children:base]               ;inherit from section "base"
children="set"

Run

lets retrieve the configurations from Yaconf

foo.ini
php7 -r 'var_dump(Yaconf::get("foo"));'
/*
array(3) {
  ["name"]=>
  string(6) "yaconf"
  ["year"]=>
  string(4) "2015"
  ["features"]=>
  array(5) {
    [0]=>
    string(4) "fast"
    [1]=>
    string(5) "light"
    ["plus"]=>
    string(9) "zero-copy"
    ["constant"]=>
    string(9) "7.0.0-dev"
    ["env"] =>
    string(16) "/home/huixinchen"
  }
}
*/

As you can see, Yaconf supports string, map(array), ini, env variable and PHP constants.

You can also access configurations like this:

php7 -r 'var_dump(Yaconf::get("foo.name"));'
//string(6) "yaconf"

php7 -r 'var_dump(Yaconf::get("foo.features.1"));'
//string(5) "light"

php7 -r 'var_dump(Yaconf::get("foo.features")["plus"]);'
//string(9) "zero-copy"
bar.ini

Now let's see the sections and sections inheritance:

php7 -r 'var_dump(Yaconf::get("bar"));'
/*
array(2) {
  ["base"]=>
  array(2) {
    ["parent"]=>
    string(6) "yaconf"
    ["children"]=>
    string(4) "NULL"
  }
  ["children"]=>
  array(2) {
    ["parent"]=>
    string(6) "yaconf"
    ["children"]=>
    string(3) "set"
  }
}
*/

Children section has inherited values in base sections, and children is able to override the values they want.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].