PHPackages                             rehmat/coffee-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. rehmat/coffee-config

ActiveLibrart[Utility &amp; Helpers](/categories/utility)

rehmat/coffee-config
====================

Config reader

V1.0(6y ago)410[1 PRs](https://github.com/RehmatFalcon/CoffeeConfig/pulls)MITPHPCI passing

Since Nov 14Pushed 3w agoCompare

[ Source](https://github.com/RehmatFalcon/CoffeeConfig)[ Packagist](https://packagist.org/packages/rehmat/coffee-config)[ RSS](/packages/rehmat-coffee-config/feed)WikiDiscussions master Synced yesterday

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

CoffeeConfig
============

[](#coffeeconfig)

A simple library for retrieving configuration.

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

[](#installation)

You can install this library through composer

> composer require rehmat/coffee-config

Usage
-----

[](#usage)

You can set the config using the Coffee\\Config\\AppConfig class.

> AppConfig::setAppConfig($configData);

Here $configData is an php array with your data.

```
$configData = [
  'app' => [
    'key' => 'YOUR_APP_KEY',
    'db_name' => 'DB_NAME',
    'routes' => [
      'web' => [
        'home' => [
          'route' => '/home',
          'controller' => YourController::class
        ]
      ],
      'console' => [
        'login' => [
          'command' => 'login',
          'controller' => YourController::class
        ]
      ]
    ]
  ]
];
Coffee\Config\AppConfig::setAppConfig($configData);
```

To retrieve the appconfig, use the getAppConfig method.

> $appConfig = Coffee\\Config\\AppConfig::getAppConfig();

However, if the app config is not set, it will throw a Coffee\\Config\\Exception\\AppConfigNotSetException . So, you could check if the config is set or not beforehand using the hasAppConfigSet method.

> $hasConfigSet = Coffee\\Config\\AppConfig::hasAppConfigSet();

Retrieve Config
---------------

[](#retrieve-config)

AppConfig::getAppConfig() returns an instance of Coffee\\Config\\Config .

To retrieve the values within your config, use the get method.

In the above config, to retrieve the value of the 'app' key, use $config-&gt;get('key'); This will return another Config instance with from where you can query data inside child nodes of 'app' or get the array as a whole using the getValue method.

```
$configFromAppNode = $appConfig->get('app');
$appNodeData = $configFromAppNode->getValue();
```

You can retrieve the values further down the tree using this method.

```
$homeController = $appConfig->get('app')->get('routes')->get('web')->get('home')->get('controller')->getValue();
```

However, it can quickly get too verbose. Luckily, you could do the same using a path expression, where you specify the path till the config you would need.

```
- $homeController = $appConfig->get('app')->get('routes')->get('web')->get('home')->get('controller')->getValue();
+ $homeController = $appConfig->get('app/routes/web/home/controller')->getValue();
```

If you specify an invalid path, i.e. the path that does not exist, then it will throw an Coffee\\Config\\Exception\\InvalidConfigPathException .

Infact, you could use this path expression in the AppConfig itself, using the AppConfig::get($path) method. However, this method is only provided as helper and you are suggested to first retrieve the app config using the getAppConfig method and use its get method.

If you call the get method on a LeafNode, it will throw an Coffee\\Config\\Exception\\LeafNodeException . A node or config is a leaf node, if it does not have any child. 'db\_name' is a leaf node as it does not have any child. In a leaf node, you can only retrieve its value using the getValue method.

You can use the isLeaf method of the config instance to check if it is a leaf node or not.

### Conclusion

[](#conclusion)

Use this library to store you app configuration and retrieve it. This library will provide you with a fluent interface to your application configuration. This library does not care how the configuration is stored. So, it can be used with most of the php project with minimal configuration.

Ensure that you call the AppConfig::setAppConfig() with appropriate data when you application starts, in index.php for example.

Happy Coding !!

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance62

Regular maintenance activity

Popularity9

Limited adoption so far

Community6

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

2371d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2c5c4d9de4fa8c81976e85886cebbd876e2a11e1d80a8ee061b5974dca79e2ac?d=identicon)[RehmatFalcon](/maintainers/RehmatFalcon)

---

Top Contributors

[![niroula-kushal](https://avatars.githubusercontent.com/u/28915667?v=4)](https://github.com/niroula-kushal "niroula-kushal (5 commits)")

### Embed Badge

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

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

###  Alternatives

[ramsey/devtools

A Composer plugin to aid PHP library and application development.

7134.7k26](/packages/ramsey-devtools)[jimbojsb/workman

PHP process forking &amp; daemonizing library

608.8k](/packages/jimbojsb-workman)

PHPackages © 2026

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