PHPackages                             xy2z/lite-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. xy2z/lite-config

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

xy2z/lite-config
================

A lightweight PHP static class with zero dependencies.

1.2.3(3mo ago)63964[1 issues](https://github.com/xy2z/LiteConfig/issues)[2 PRs](https://github.com/xy2z/LiteConfig/pulls)1MITPHP

Since Sep 21Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/xy2z/LiteConfig)[ Packagist](https://packagist.org/packages/xy2z/lite-config)[ GitHub Sponsors](https://github.com/sponsors/xy2z)[ RSS](/packages/xy2z-lite-config/feed)WikiDiscussions master Synced 1mo ago

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

LiteConfig
==========

[](#liteconfig)

A lightweight PHP static class with zero dependencies.

Supports multiple configs and multidimensional arrays.

Built-in support for PHP, INI and JSON files. Also supports YAML and anything else you can parse to an array, see [custom\_handler()](#custom-handler) below.

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

[](#requirements)

- PHP 7.0 +

Install
-------

[](#install)

```
composer require xy2z/lite-config
```

Examples
--------

[](#examples)

```
require 'path/to/vendor/autoload.php';
use xy2z\LiteConfig\LiteConfig as Config;
```

#### Array

[](#array)

```
Config::loadArray([
  'version' => '1.0',
  'app' => [
      'name' => 'Example'
  ]
]);

echo Config::get('version'); # 1.0
echo Config::get('app'); # Array('name' => 'Example')
echo Config::get('app.name', 'default name'); # Example
echo Config::get('app.type', 'Desktop'); # Desktop
```

#### Directory

[](#directory)

```
# config/settings.php
return [
  'app_name' => 'Example',
];

# index.php
Config::loadDir('config/', true);
echo Config::get('settings.app_name'); # key is 'filename.key'
```

#### Single file

[](#single-file)

```
# No key prefix
Config::loadFile('config/settings.php');
echo Config::get('key');

# Prefix filename to key
Config::loadFile('config/db.ini', true);
echo Config::get('db.key');
```

#### YAML

[](#yaml)

To load a single file as YAML see below. If you need to use `loadDir()` with yaml (or other) files, then read about "Custom Handler" below.

```
composer require symfony/yaml
```

```
use xy2z\LiteConfig\LiteConfig as Config;
use Symfony\Component\Yaml\Yaml;

Config::loadArray(Yaml::parseFile(__DIR__ . '/config/file.yml'));

echo Config::get('key');
```

#### Custom Handler

[](#custom-handler)

A custom handler can be used for file extensions other than the built in (.php, .json and .ini). This will automatically work when using the `loadFile()` and `loadDir()` functions.

Here's how you use the static `custom_handler()` function if you want YAML support.

```
use xy2z\LiteConfig\LiteConfig;
use Symfony\Component\Yaml\Yaml;

class CustomLiteConfig extends LiteConfig {

    protected static function custom_handler(string $extension, string $path) {
        if (($extension === 'yml') || ($extension === 'yaml')) {
            return Yaml::parseFile($path);
        }

        // Handle other extensions here...
    }

}

CustomLiteConfig::loadDir(__DIR__ . '/config', true);
var_dump(CustomLiteConfig::all());
```

If you want to modify the existing handling of all files, you can overwrite the complete `getFileContent()` function in your child class, which is used by `loadDir()` and `loadFile()`.

Public Methods
--------------

[](#public-methods)

- `get(string $key, $default = null)` Get value of key.
- `all()` Returns a complete array.
- `exists(string $key)` Does key exist?
- `loadDir(string $path, bool $prefix_filename = false, string $prefix = null)` Loads all files in dir.
- `loadFile(string $path, bool $prefix_filename = false, string $custom_prefix = null)` Load a single file.
- `loadArray(array $array, string $prefix = null)` Loads a php array.

### Public Properties

[](#public-properties)

- `ini_process_sections` (bool, default `true`) - Argument used in file\_parse\_ini()
- `ini_scanner_mode` (int, default `INI_SCANNER_TYPED`) - Argument used in file\_parse\_ini()
- `ignore_unsupported_filestypes` (bool, default `true`) - If true, files with unsupported extensions will be ignored. If false, an exception will be thrown.

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance77

Regular maintenance activity

Popularity21

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 81.8% 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 ~337 days

Recently: every ~376 days

Total

9

Last Release

100d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5d4c08a97e1c9c53efb123c306f551fcb367e8adea3bfa1412c49c8e5133aeff?d=identicon)[xy2z](/maintainers/xy2z)

---

Top Contributors

[![xy2z](https://avatars.githubusercontent.com/u/4496997?v=4)](https://github.com/xy2z "xy2z (27 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![captainswain](https://avatars.githubusercontent.com/u/808890?v=4)](https://github.com/captainswain "captainswain (2 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (1 commits)")

---

Tags

confighacktoberfestlightweightphp7php8zero-dependency

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

PHPackages © 2026

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