PHPackages                             phlib/console-configuration - 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. [CLI &amp; Console](/categories/cli)
4. /
5. phlib/console-configuration

ActiveLibrary[CLI &amp; Console](/categories/cli)

phlib/console-configuration
===========================

Console Configuration Helper implementation.

3.0.1(1y ago)043.0k↓25.8%13LGPL-3.0PHPPHP ^8.1CI passing

Since Nov 20Pushed 1y ago5 watchersCompare

[ Source](https://github.com/phlib/console-configuration)[ Packagist](https://packagist.org/packages/phlib/console-configuration)[ RSS](/packages/phlib-console-configuration/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (16)Used By (3)

phlib/console-configuration
===========================

[](#phlibconsole-configuration)

[![Code Checks](https://camo.githubusercontent.com/ea6501e1a895e52b2d3694274ee4780c3f1da1c03a137004b7e8c4168a61f840/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f70686c69622f636f6e736f6c652d636f6e66696775726174696f6e2f636f64652d636865636b732e796d6c3f6c6f676f3d676974687562)](https://github.com/phlib/console-configuration/actions/workflows/code-checks.yml)[![Codecov](https://camo.githubusercontent.com/f9fb181e4c48cd060173441229b92ee32dd03c2bd4e9daf656f1d9054118f250/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f70686c69622f636f6e736f6c652d636f6e66696775726174696f6e2e7376673f6c6f676f3d636f6465636f76)](https://codecov.io/gh/phlib/console-configuration)[![Latest Stable Version](https://camo.githubusercontent.com/3e652962359d99b1f1790dfb8603938549d778e8a91a4f377e42c8c7fbe6c147/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70686c69622f636f6e736f6c652d636f6e66696775726174696f6e2e7376673f6c6f676f3d7061636b6167697374)](https://packagist.org/packages/phlib/console-configuration)[![Total Downloads](https://camo.githubusercontent.com/afaab0bc64a22e6cb6b0bda6df9732a8607c7a39660e8b395f211141359194eb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70686c69622f636f6e736f6c652d636f6e66696775726174696f6e2e7376673f6c6f676f3d7061636b6167697374)](https://packagist.org/packages/phlib/console-configuration)[![Licence](https://camo.githubusercontent.com/f547983db66d70405c12694169aef7ea68474f61b6cd8c00d68fa621f34b41e1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f70686c69622f636f6e736f6c652d636f6e66696775726174696f6e2e737667)](https://camo.githubusercontent.com/f547983db66d70405c12694169aef7ea68474f61b6cd8c00d68fa621f34b41e1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f70686c69622f636f6e736f6c652d636f6e66696775726174696f6e2e737667)

Console Configuration Helper implementation.

Install
-------

[](#install)

Via Composer

```
$ composer require phlib/console-configuration
```

Configuration Helper
--------------------

[](#configuration-helper)

Adds the `-c path/to/config.php` parameter to the console application and makes it easily accessible to all commands. This is most useful for third party libraries which rely on the configuration being specified from the options.

### Basic Usage

[](#basic-usage)

```
// your usual cli setup script

use Phlib\ConsoleConfiguration\Helper\ConfigurationHelper;

$app = new Application('my-cli');
$app->setCommands(['...']);
$helper = ConfigurationHelper::initHelper(
    $app,
    $default = ['host' => 'localhost'],
    $options = []
);
$app->run();
```

```
class MyCommand extends Command
{
    '...'

    protected function createMyObjectInstance()
    {
        $config = $this->getHelper('configuration')->fetch();
        return new MyObjectInstance($config);
    }
}
```

### Options

[](#options)

You can specify some options to setup the helper through the `initHelper` static method.

NameTypeDefaultDescription`name`*String*`'config'`The name of the option on the command line.`abbreviation`*String*`'c'`The abbreviation of the option on the command line.`description`*String*`'...'`The associated description for the option.`filename`*String*`'cli-config.php'`The filename that will be detected if no name is specified.```
ConfigurationHelper::initHelper($app, null, [
    'name' => 'config-option',
    'filename' => 'my-cli-config.php',
]);
```

Defaults
--------

[](#defaults)

With no default (`null`) specified, the fetch method returns `false`. You can specify a default configuration using the `setDefault` method or through the `initHelper` static method.

```
$helper->setDefault(['host' => 'localhost']);
```

OR

```
ConfigurationHelper::initHelper(
    $app,
    ['host' => 'localhost'],
    ['filename' => 'service-name.php']
);
```

Use Case: Autodetect with no command line option
------------------------------------------------

[](#use-case-autodetect-with-no-command-line-option)

```
$app = new Application('my-cli');
$app->setCommands(['...']);
$app->getHelperSet()->set(new ConfigurationHelper('config', 'my-config.php'));
$app->run();
```

License
-------

[](#license)

This package is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see .

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance42

Moderate activity, may be stable

Popularity28

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 98% 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 ~239 days

Recently: every ~323 days

Total

15

Last Release

473d ago

Major Versions

0.2.1 → 1.0.02015-12-14

1.1.2 → 2.0.02021-07-18

2.0.2 → 3.0.02025-01-27

PHP version history (5 changes)0.1PHP ~5.4

1.0.1PHP &gt;=5.4

1.1.1PHP ^5.4|^7

2.0.0PHP ^7.3|^8.0

3.0.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/135b7ddf9ec91c412e1b18174f81d1ad2bef66e732624195c156717c96b13731?d=identicon)[letssurf](/maintainers/letssurf)

![](https://www.gravatar.com/avatar/10c53cdcfb3a6d299820aecb993521cc1a972baa09fd8f31d2468908cded7e1d?d=identicon)[chrisminett](/maintainers/chrisminett)

---

Top Contributors

[![chrisminett](https://avatars.githubusercontent.com/u/1084019?v=4)](https://github.com/chrisminett "chrisminett (49 commits)")[![Fahrenholz](https://avatars.githubusercontent.com/u/7955008?v=4)](https://github.com/Fahrenholz "Fahrenholz (1 commits)")

---

Tags

consolesymfonyhelperconfigurationoption

###  Code Quality

TestsPHPUnit

Code StyleECS

### Embed Badge

![Health badge](/badges/phlib-console-configuration/health.svg)

```
[![Health](https://phpackages.com/badges/phlib-console-configuration/health.svg)](https://phpackages.com/packages/phlib-console-configuration)
```

###  Alternatives

[nunomaduro/collision

Cli error handling for console/command-line PHP applications.

4.6k331.8M8.5k](/packages/nunomaduro-collision)[drupal/console-core

Drupal Console Core

13514.7M12](/packages/drupal-console-core)[matthiasnoback/symfony-console-form

Use Symfony forms for Console command input

368264.8k8](/packages/matthiasnoback-symfony-console-form)[phlib/console-process

Console implementation.

1833.5k2](/packages/phlib-console-process)

PHPackages © 2026

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