PHPackages                             sugiphp/config - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. sugiphp/config

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

sugiphp/config
==============

SugiPHP Config Component

1.0.0(11y ago)41.2k12MITPHPPHP &gt;=5.3

Since Dec 16Pushed 10y ago2 watchersCompare

[ Source](https://github.com/SugiPHP/Config)[ Packagist](https://packagist.org/packages/sugiphp/config)[ RSS](/packages/sugiphp-config/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (2)

Config
======

[](#config)

[![Build Status](https://camo.githubusercontent.com/f8264ef04cb89e0dd36e636c1e243443b81c1aff6cba045b58fad142eb4ae2c0/68747470733a2f2f7472617669732d63692e6f72672f537567695048502f436f6e6669672e706e67)](https://travis-ci.org/SugiPHP/Config)

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

[](#installation)

```
composer require sugiphp/config ~1.0
```

SugiPHP\\Config is designed to simplify access to configuration settings. Config class natively supports reading and parsing configuration options from several file types (php, json, yaml, ini, xml) stored in one or several locations in your project. Config::get("file.key") method automatically finds configuration file, loads it, parses it and then searches for the key and returns it's value. If the file or the key is not found gracefully returns NULL or some other default value if it is provided like a second parameter.

Usage
-----

[](#usage)

You can use different file types to store settings:

- PHP (with filename app.php)

```

```

- JSON (app.json)

```
{
	"development": {
		"host": "localhost",
		"debug": 1
	},
	"production": {
		"host": "example.com"
	}
}
```

- YAML (app.yml)

```
development:
	host: localhost
	debug: 1

production:
	host: example.com
```

- INI (app.ini)

```
[development]
host=localhost
debug=1

[production]
host=example.com
```

- XML (app.xml)

```

		localhost
		1

		example.com

```

To access the host option no matter wich type of configurations file you use:

```

```

FileLocator
-----------

[](#filelocator)

FileLocator is used to search for a (configuration) file in one or more directories.

```

```

Loader
------

[](#loader)

A loader binds a key with a corresponding value which can be found somewhere (in a file, in a database, etc.) and can be in any form (a php array, json string, xml, etc.). A simple example that explains a loader: Lets assume your application resides in a "/path/to/app", and your configuration files are in "/path/to/app/config" path. Your application needs a database connection. The host, database, user and password are described in a PHP file living in configuration directory. You can use a loader which will include a file (a $key = "database" with ".php" extension) in that folder and return the contents, like the PHP code will do:

```

```

A slightly more complicated example is when a database is described in an json format. So the loader will do something like:

```

```

Another example is if some of your app configurations are stored not in files but lets say in a NoSQL storage. So you can write your custom loader which will connect to the NoSQL DB, fetch items and return them as array. And that's really easy, and the better thing is that your existing code will not need any modification.

You can peek in [Database Loader](tests/Db1Loader.php) for a simple database configuration store example.

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity58

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

Unknown

Total

1

Last Release

4215d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/991c2430ace2ac70cb06507ae39e9e556e43bff5380e45ddd72c0f0294347794?d=identicon)[tzappa](/maintainers/tzappa)

---

Top Contributors

[![tzappa](https://avatars.githubusercontent.com/u/140298?v=4)](https://github.com/tzappa "tzappa (42 commits)")

---

Tags

phpjsonconfigurationxmlconfigyamlini

### Embed Badge

![Health badge](/badges/sugiphp-config/health.svg)

```
[![Health](https://phpackages.com/badges/sugiphp-config/health.svg)](https://phpackages.com/packages/sugiphp-config)
```

###  Alternatives

[hassankhan/config

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

1.0k13.8M184](/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)[davidepastore/slim-config

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

339.0k1](/packages/davidepastore-slim-config)[thewunder/conphigure

Framework Agnostic Configuration Library

3119.1k](/packages/thewunder-conphigure)[phppkg/config

Config manage, load, get. Supports INI,JSON,YAML,NEON,PHP format file

133.5k](/packages/phppkg-config)

PHPackages © 2026

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