PHPackages                             alcamo/conf - 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. alcamo/conf

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

alcamo/conf
===========

Simple reading of conf files from XDG base directories

0.6.7(2mo ago)097Apache-2.0PHPPHP 7.3 - 8.0

Since Jun 30Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/rv1971/alcamo-conf)[ Packagist](https://packagist.org/packages/alcamo/conf)[ RSS](/packages/alcamo-conf/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (8)Versions (17)Used By (0)

Usage examples
==============

[](#usage-examples)

```
use alcamo\conf\{Loader, XdgFileFinder}

$conf = (new Loader(new XdgFileFinder('foo')))->Load(
    [ 'default.ini', 'conf.ini' ]
);

```

Now `$conf` contains an array representing the contents of `$XDG_CONFIG_HOME/foo/default.ini` and `$XDG_CONFIG_HOME/foo/conf.ini`, where items in the latter replace items in the former with the same key, if `$XDG_CONFIG_HOME` is set. Otherwise, `foo/conf.ini` is searched as specified in the [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)

```
use alcamo\conf\{Loader as LoaderBase, XdgFileFinder as XdgFileFinderBase}

class XdgFileFinder extends XdgFileFinderBase
{
    public const SUBDIR = 'foo';
}

class Loader extends LoaderBase
{
    public const DEFAULT_FILE_PARSER_CLASS = XdgFileFinder::class;

    public const CONF_FILES = [ 'default.ini' ];
}

$conf = (new Loader())->Load('conf.ini');

```

This has exactly the same effect and may be more useful if configurations are loaded from the same subdirectory in many places in the code, in particular when there is a common basic configuration files plus specific configuration files.

```
use alcamo\conf\{Loader as LoaderBase, XdgFileFinder as XdgFileFinderBase}

class XdgFileFinder extends XdgFileFinderBase
{
    public const SUBDIR = 'bar';
}

$cacheFilename = (new XdgFileFinder(null, 'CACHE'))->find('data.json');

```

Now, `$cacheFilename` contains `$XDG_CACHE_HOME/bar/data.json` if `$XDG_CACHE_HOME` is set. Otherwise, the path is constructed as specified in the XDG Base Directory Specification. If the directory `$XDG_CACHE_HOME/bar` did not exist, it has been created automatically.

Supplied interfaces, classes and traits
=======================================

[](#supplied-interfaces-classes-and-traits)

Interface `FileFinderInterface`
-------------------------------

[](#interface-filefinderinterface)

Interface for configuration file finders to put into a Loader object.

Class `XdgFileFinder`
---------------------

[](#class-xdgfilefinder)

Finds config files and other files following the XDG Base Directory Specification.

Interface `FileParserInterface`
-------------------------------

[](#interface-fileparserinterface)

Interface for file parsers to put into a Loader object.

Class `IniFileParser`
---------------------

[](#class-inifileparser)

Parser for INI files.

Class `JsonFileParser`
----------------------

[](#class-jsonfileparser)

Parser for JSON files.

Class `FileParser`
------------------

[](#class-fileparser)

Parser for INI or JSON files, telling the file type from the suffix.

Interface `LoaderInterface`
---------------------------

[](#interface-loaderinterface)

Interface implemented by the Loader class.

Class `Loader`
--------------

[](#class-loader)

Contains a file finder and a file parser object and uses them to locate and load file or a nuimber of files.

Interface `HavingConfInterface`
-------------------------------

[](#interface-havingconfinterface)

Class that provides an array with configuration data.

Trait `HavingConfTrait`
-----------------------

[](#trait-havingconftrait)

Simple implementation of HavingConfInterface.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance86

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

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 ~114 days

Recently: every ~16 days

Total

16

Last Release

68d ago

PHP version history (2 changes)0.1PHP 7.3 - 7.4

0.1.1PHP 7.3 - 8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/db9722b60c5a69929f1d1c7df3d0d8682d74ed19146a2cdd2dfffa7ddc4abc78?d=identicon)[rv1971](/maintainers/rv1971)

---

Top Contributors

[![rv1971](https://avatars.githubusercontent.com/u/39520256?v=4)](https://github.com/rv1971 "rv1971 (18 commits)")

---

Tags

configurationconfxdg

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/alcamo-conf/health.svg)

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

###  Alternatives

[symfony/options-resolver

Provides an improved replacement for the array\_replace PHP function

3.2k493.9M1.6k](/packages/symfony-options-resolver)[league/config

Define configuration arrays with strict schemas and access values with dot notation

564302.2M24](/packages/league-config)[josegonzalez/dotenv

dotenv file parsing for PHP

2799.8M137](/packages/josegonzalez-dotenv)[dflydev/dot-access-configuration

Given a deep data structure representing a configuration, access configuration by dot notation.

13414.5M4](/packages/dflydev-dot-access-configuration)[symfony/requirements-checker

Check Symfony requirements and give recommendations

2014.7M29](/packages/symfony-requirements-checker)[chillerlan/php-settings-container

A container class for immutable settings objects. Not a DI container.

3427.3M21](/packages/chillerlan-php-settings-container)

PHPackages © 2026

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