PHPackages                             ibnusyuhada/slim-lite-configuration - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. ibnusyuhada/slim-lite-configuration

ActiveLibrary[Framework](/categories/framework)

ibnusyuhada/slim-lite-configuration
===================================

Slim Lite Configuration is a file(s) configuration loader for Slim Framework Middleware. Just say the file(s), then Slim Lite Configuration will register the configuration items automatically to Slim settings. This package support with Ini, Php, Json, Xml, Yaml format. If need to change the configuration file, this package can do as you want.

v0.0.2(10y ago)057MITPHPPHP &gt;=5.3.0

Since Jun 30Pushed 10y ago1 watchersCompare

[ Source](https://github.com/ibnusyuhadap3/slim-lite-configuration)[ Packagist](https://packagist.org/packages/ibnusyuhada/slim-lite-configuration)[ RSS](/packages/ibnusyuhada-slim-lite-configuration/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)Dependencies (5)Versions (3)Used By (0)

Slim Lite Configuration
=======================

[](#slim-lite-configuration)

[![Latest Stable Version](https://camo.githubusercontent.com/88b6ddeb4f087d9f21988940649877a113f434022e84400e7d9746f011cda011/68747470733a2f2f706f7365722e707567782e6f72672f69626e75737975686164612f736c696d2d6c6974652d636f6e66696775726174696f6e2f762f737461626c65)](https://packagist.org/packages/ibnusyuhada/slim-lite-configuration) [![License](https://camo.githubusercontent.com/3f86c822fffd5de4c87ae1f8925db2ef17301d03b7555cb47d50b01a7c482a65/68747470733a2f2f706f7365722e707567782e6f72672f69626e75737975686164612f736c696d2d6c6974652d636f6e66696775726174696f6e2f6c6963656e7365)](https://github.com/ibnusyuhadap3/slim-lite-configuration/blob/master/LICENSE.md) [![Total Downloads](https://camo.githubusercontent.com/5886dda2c3dd1215ac8ce7ca48adde9f5f46165c92f2e1fd73fe0ab5f9ee2aa3/68747470733a2f2f706f7365722e707567782e6f72672f69626e75737975686164612f736c696d2d6c6974652d636f6e66696775726174696f6e2f646f776e6c6f616473)](https://packagist.org/packages/ibnusyuhada/slim-lite-configuration) [![Build Status](https://camo.githubusercontent.com/9ee323accf9b77a113cff2df5802c26eb75e257a2acfe388a6c8800f1efca9cd/68747470733a2f2f7472617669732d63692e6f72672f69626e757379756861646170332f736c696d2d6c6974652d636f6e66696775726174696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ibnusyuhadap3/slim-lite-configuration)

Slim Lite Configuration is a file(s) configuration loader for [Slim Framework Middleware](http://www.slimframework.com/). Just say the file(s), then Slim Lite Configuration will register the configuration items automatically to Slim settings. This package support with Ini, Php, Json, Xml, Yaml format. If need to change the configuration file, this package can do as you want.

Requirements
------------

[](#requirements)

Slim Lite Configuration requires PHP 5.3+ and works for Slim Framework v3.0.0 or above.

Installation
------------

[](#installation)

The easiest way to installing Slim Lite Configuration is via Composer

```
composer require ibnusyuhada/slim-lite-configuration

```

Usage
-----

[](#usage)

Slim Lite Configuration designed to be simple to use in Slim Framework. You only register the file(s) or directory of config file(s), then configuration immediately ready for use. When you need to change the items of configuration in a file, just say the path file. Internally uses [hassankhan config](https://github.com/hassankhan/config).

### Loading Files

[](#loading-files)

Slim Lite Configuration able to load one file or multiple files or optional files at same time. Rather than say the file name one by one, you can add the directory of files then configuration ready to use. Initially register Slim Lite Configuration to container

```
// start Slim Framework
$app = new \Slim\App();

// call Slim Container
$container = $app->getContainer();

// register Slim Lite Configuration

// if want to register all files inside directory choose this one
$container["config"] = function ($container){
	return new IS\Slim\LiteConfiguration\Configuration(__DIR__ . "/../config",$container);
};

// if want to register a file choose this one
$container["config"] = function ($container){
	return new IS\Slim\LiteConfiguration\Configuration(__DIR__ . "/../config/config.yaml",$container);
};

// if want to register several files choose this one
$container["config"] = function ($container){
	return new IS\Slim\LiteConfiguration\Configuration([__DIR__ . "/../config/config.yaml", __DIR__ . "/../config/config.php"],$container);
};

// if want to register optional files choose this one
$container["config"] = function ($container){
	return new IS\Slim\LiteConfiguration\Configuration(["config.yaml","?config.php"],$container);
};

```

### Register Per Route

[](#register-per-route)

As middleware, after register Slim Lite Configuration into container, then we can register all items of configuration in specific route.

```
// configuration only available in this route
$app->get("/", function($req,$res,$args){
	var_dump($this->settings);
})->add($container->get("config"));

```

### Register For All Routes

[](#register-for-all-routes)

But, if you want all configuration are available for all routes, just do like code below

```
$app = new \Slim\App;
$container = $app->getContainer();
$container["config"] = function ($container){
	return new IS\Slim\LiteConfiguration\Configuration(__DIR__ . "/../config/config.yaml",$container);
};

// register for all routes
$app->add($container->get("config"));

$app->get("/", function($req,$res,$args){
	var_dump($this->settings);
});

$app->get("/blog", function($req,$res,$args){
	var_dump($this->settings);
});

$app->run();

```

### Write Or Update Configuration File

[](#write-or-update-configuration-file)

You are allowed to create a file of configuration if the request file is not exist. But you will get update if file configuration is exist. Here is the example usage in concept Slim Lite Configuration for all routes:

```
$app->get("/blog", function($req,$res,$args){
	$conf = $this->config;

	$array = [
			"coba" => "hasil",
			"first_section" => [
					"three" => 1,
					"two" => 2
			],
			"phpversion" => [
					"one","two"
			],
			"second_section" => [
					"servers" => ["host1","host2","host3"]
			]
	];

	$conf->writeConfig($array,dirname(dirname(__FILE__)) . "/config/config.yaml");
	return success;
});

```

### Access All Configuration Items

[](#access-all-configuration-items)

Let say we have a file config.yaml like below

```
db:
  host: localhost
  user: user
  pass: password
  dbname: exampleapp

```

In design, all items of configuration will be placed in Slim settings and Slim Lite Configuration container. So, when we want to get all items of configuration we can do with two possible ways in a route

```
$settings = $this->settings;
var_dump($settings);

```

or

```
$conf = $this->config;
var_dump($conf->all());

```

### Access Specific Configuration Item

[](#access-specific-configuration-item)

In fact, when we want to access specific item of configuration, it can be done with two possible ways in a route as well

```
$settings = $this->settings;
var_dump($settings["db"]["host"]);

```

or

```
$conf = $this->config;
var_dump($conf->get("db.host"));

```

### Set Configuration Item

[](#set-configuration-item)

Set new value of an item(s), there are two possible ways in a route, first is by using this way

```
$conf = $this->config;
echo $conf->get("db.host"); // output is localhost
$conf->set("db.host","ibnu");
echo $conf->get("db.host"); // output is ibnu

```

In this way, Slim Lite Configuration only update the container but not Slim settings. The second way by update file configuration like explained above.

### Safe Memory Usage

[](#safe-memory-usage)

Like explained above, Slim Lite Configuration will save the items of configuration in Slim settings and container. This will need more usage of computer memory. So to safe the memory, we can to remove Slim Lite Configuration from container by placed the code below

```
$container->offsetUnset("config");

```

elsewhere after

```
$container["config"] = function ($container){
	return new IS\Slim\LiteConfiguration\Configuration(__DIR__ . "/../config",$container);
};

```

do this way will not destroy Slim settings.

Benefits
--------

[](#benefits)

Conceptually, it is reasonable if configuration items are set in settings. It is means configuration should put in Slim settings. In Slim Lite Configuration, all items of configuration are appended in Slim settings. So basically, when you destroy Slim Lite Configuration from container, Slim settings will not change and the configuration is still exist. This is very useful, because we only focus on access of configuration via Slim settings only and of course we can safe memory. There is a condition where specific request URI has different configuration, and at this point Slim Lite Configuration as middleware is able to do this condition.

Testing
-------

[](#testing)

```
$phpunit

```

Credits
-------

[](#credits)

[Ibnu Syuhada](https://github.com/ibnusyuhadap3)

License
-------

[](#license)

The MIT License. See the [License](https://github.com/ibnusyuhadap3/slim-lite-configuration/blob/master/LICENCE.md)

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

3652d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/87265564?v=4)[Ibnu syuhada](/maintainers/ibnusyuhada)[@ibnusyuhada](https://github.com/ibnusyuhada)

---

Top Contributors

[![ibnusyuhadap3](https://avatars.githubusercontent.com/u/7171457?v=4)](https://github.com/ibnusyuhadap3 "ibnusyuhadap3 (26 commits)")

---

Tags

phpjsonmiddlewareframeworkconfigurationxmlyamlymlslimliteiniautomatically

### Embed Badge

![Health badge](/badges/ibnusyuhada-slim-lite-configuration/health.svg)

```
[![Health](https://phpackages.com/badges/ibnusyuhada-slim-lite-configuration/health.svg)](https://phpackages.com/packages/ibnusyuhada-slim-lite-configuration)
```

###  Alternatives

[davidepastore/slim-config

A slim middleware to read configuration from different files based on hassankhan/config

339.0k1](/packages/davidepastore-slim-config)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[php-curl-class/php-curl-class

PHP Curl Class makes it easy to send HTTP requests and integrate with web APIs.

3.3k9.8M372](/packages/php-curl-class-php-curl-class)[hassankhan/config

Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files

97413.7M184](/packages/hassankhan-config)[m1/vars

Vars is a simple to use and easily extendable configuration loader with in built loaders for ini, json, PHP, toml, XML and yaml/yml file types. It also comes with in built support for Silex and more frameworks to come soon.

64124.3k1](/packages/m1-vars)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
