PHPackages                             lukman-ss/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. lukman-ss/config

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

lukman-ss/config
================

Standalone PHP configuration repository, env loader, file loader, and cache utility.

v1.0.0(today)10MITPHPPHP &gt;=8.2

Since Jun 13Pushed todayCompare

[ Source](https://github.com/lukman-ss/config)[ Packagist](https://packagist.org/packages/lukman-ss/config)[ RSS](/packages/lukman-ss-config/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (1)Versions (2)Used By (0)

lukman-ss/config
================

[](#lukman-ssconfig)

[![Hero Banner](docs/hero_banner.png)](docs/hero_banner.png)

Standalone PHP configuration library with a repository, typed getters, `.env` loading, PHP config file loading, cache files, and freeze mode.

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

[](#requirements)

- PHP 8.2 or higher
- No runtime dependencies

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

[](#installation)

```
composer require lukman-ss/config
```

Basic Usage
-----------

[](#basic-usage)

```
use Lukman\Config\Config;

$config = new Config();

$config
    ->set('app.name', 'Demo')
    ->set('app.debug', true);

$name = $config->string('app.name');
$debug = $config->bool('app.debug');
```

Repository
----------

[](#repository)

```
use Lukman\Config\Repository;

$repository = new Repository([
    'database' => [
        'host' => '127.0.0.1',
    ],
]);

$repository->set('database.port', 3306);

$host = $repository->get('database.host');
$port = $repository->int('database.port');
$all = $repository->all();
```

Env Loader
----------

[](#env-loader)

```
use Lukman\Config\EnvLoader;

$env = new EnvLoader();
$values = $env->load(__DIR__ . '/.env');
```

Supported scalar parsing:

- `true` and `false` to boolean
- `null` to null
- integers and floats to numeric values
- quoted values remain strings
- empty values remain empty strings

Config File Loader
------------------

[](#config-file-loader)

```
use Lukman\Config\ConfigLoader;

$loader = new ConfigLoader();
$items = $loader->load(__DIR__ . '/config');
```

Only non-recursive `*.php` files are loaded. Each file must return an array. The filename becomes the namespace key.

Example `config/app.php`:

```
