All Projects → DavidePastore → Slim-Config

DavidePastore / Slim-Config

Licence: other
A file configuration loader that supports PHP, INI, XML, JSON, and YML files for the Slim Framework. It internally uses https://github.com/hassankhan/config.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to Slim-Config

parse it
A python library for parsing multiple types of config files, envvars & command line arguments that takes the headache out of setting app configurations.
Stars: ✭ 86 (+207.14%)
Mutual labels:  config, yaml, ini
Config
📝 Go config manage(load,get,set). support JSON, YAML, TOML, INI, HCL, ENV and Flags. Multi file load, data override merge, parse ENV var. Go应用配置加载管理,支持多种格式,多文件加载,远程文件加载,支持数据合并,解析环境变量名
Stars: ✭ 225 (+703.57%)
Mutual labels:  config, yaml, ini
Cfgdiff
diff(1) all your configs
Stars: ✭ 138 (+392.86%)
Mutual labels:  config, yaml, ini
Config
PHP library for simple configuration management
Stars: ✭ 39 (+39.29%)
Mutual labels:  config, yaml, ini
Konf
A type-safe cascading configuration library for Kotlin/Java/Android, supporting most configuration formats
Stars: ✭ 225 (+703.57%)
Mutual labels:  config, yaml
Simple Settings
A simple way to manage your project settings.
Stars: ✭ 165 (+489.29%)
Mutual labels:  config, yaml
Vscode Data Preview
Data Preview 🈸 extension for importing 📤 viewing 🔎 slicing 🔪 dicing 🎲 charting 📊 & exporting 📥 large JSON array/config, YAML, Apache Arrow, Avro, Parquet & Excel data files
Stars: ✭ 245 (+775%)
Mutual labels:  config, yaml
luban
你的最佳游戏配置解决方案 {excel, csv, xls, xlsx, json, bson, xml, yaml, lua, unity scriptableobject} => {json, bson, xml, lua, yaml, protobuf(pb), msgpack, flatbuffers, erlang, custom template} data + {c++, java, c#, go(golang), lua, javascript(js), typescript(ts), erlang, rust, gdscript, protobuf schema, flatbuffers schema, custom template} code。
Stars: ✭ 1,660 (+5828.57%)
Mutual labels:  config, yaml
Dynaconf
Configuration Management for Python ⚙
Stars: ✭ 2,082 (+7335.71%)
Mutual labels:  config, yaml
ini
📝 Go INI config management. support multi file load, data override merge. parse ENV variable, parse variable reference. Dotenv file parse and loader. INI配置读取管理,支持多文件加载,数据覆盖合并, 解析ENV变量, 解析变量引用。DotEnv 解析加载
Stars: ✭ 72 (+157.14%)
Mutual labels:  config, ini
libconfini
Yet another INI parser
Stars: ✭ 106 (+278.57%)
Mutual labels:  config, ini
Gcfg
read INI-style configuration files into Go structs; supports user-defined types and subsections
Stars: ✭ 146 (+421.43%)
Mutual labels:  config, ini
exenv
Exenv makes loading environment variables from external sources easy.
Stars: ✭ 35 (+25%)
Mutual labels:  config, yaml
Gray Matter
Contributing Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Stars: ✭ 2,105 (+7417.86%)
Mutual labels:  config, yaml
cfg-rs
A Configuration Library for Rust Applications
Stars: ✭ 18 (-35.71%)
Mutual labels:  config, yaml
climatecontrol
Python library for loading settings and config data from files and environment variables
Stars: ✭ 20 (-28.57%)
Mutual labels:  config, yaml
plaster
Application config settings abstraction layer.
Stars: ✭ 19 (-32.14%)
Mutual labels:  config, ini
Data
Extended implementation of ArrayObject - useful collection for any config in your system (write, read, store, change, validate, convert to other format and etc).
Stars: ✭ 77 (+175%)
Mutual labels:  config, ini
Config Lite
A super simple & flexible & useful config module.
Stars: ✭ 78 (+178.57%)
Mutual labels:  config, yaml
libconfigini
Configuration parser library in INI format
Stars: ✭ 32 (+14.29%)
Mutual labels:  config, ini

Slim Framework Config

Latest version Build Status Coverage Status Quality Score Total Downloads PSR2 Conformance

A file configuration loader that supports PHP, INI, XML, JSON, and YML files for the Slim Framework. It internally uses hassankhan/config.

Install

Via Composer

$ composer require davidepastore/slim-config

Requires Slim 3.0.0 or newer.

Usage

In most cases you want to register DavidePastore\Slim\Config for a single route, however, as it is middleware, you can also register it for all routes.

Register per route

$app = new \Slim\App();

// Fetch DI Container
$container = $app->getContainer();

// Register provider
$container['config'] = function () {
  //Create the configuration
  return new \DavidePastore\Slim\Config\Config('config.json');
};

$app->get('/api/myEndPoint',function ($req, $res, $args) {
    //Here you have your configuration
    $config = $this->config->getConfig();
    $secret = $config->get('security.secret');
})->add($container->get('config'));

$app->run();

Register for all routes

$app = new \Slim\App();

// Fetch DI Container
$container = $app->getContainer();

// Register provider
$container['config'] = function () {
  //Create the configuration
  return new \DavidePastore\Slim\Config\Config('config.json');
};

// Register middleware for all routes
// If you are implementing per-route checks you must not add this
$app->add($container->get('config'));

$app->get('/foo', function ($req, $res, $args) {
  //Here you have your configuration
  $config = $this->config->getConfig();
  $secret = $config->get('security.secret');
});

$app->post('/bar', function ($req, $res, $args) {
  //Here you have your configuration
  $config = $this->config->getConfig();
  $ttl = $config->get('app.timeout', 3000);
});

$app->run();

Where are the benefits?

The configuration is loaded from the filesystem only when the given route is called in the per route usage. In the other case (all routes) the config should be general and used in the whole routes, because it's read in every request.

Just the tip of the iceberg!

You can read the hassankhan/config documentation here for more info.

Testing

$ phpunit

Contributing

Please see CONTRIBUTING for details.

Credits

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].