PHPackages                             railt/discovery - 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. railt/discovery

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

railt/discovery
===============

Cross-package composer-based configuration loader

1.3.1(5y ago)33.4k11MITPHPPHP ^7.1.3

Since Jan 3Pushed 2y ago1 watchersCompare

[ Source](https://github.com/railt/discovery)[ Packagist](https://packagist.org/packages/railt/discovery)[ Docs](http://railt.org)[ RSS](/packages/railt-discovery/feed)WikiDiscussions 1.4.x Synced 3d ago

READMEChangelog (4)Dependencies (3)Versions (8)Used By (1)

 [![Railt](https://camo.githubusercontent.com/0b50c2bf674e95ba4fc92f5ac922a73a5b58bf284e5b44808fe5e30c674b2ca5/68747470733a2f2f7261696c742e6f72672f696d616765732f6c6f676f2d6461726b2e737667)](https://camo.githubusercontent.com/0b50c2bf674e95ba4fc92f5ac922a73a5b58bf284e5b44808fe5e30c674b2ca5/68747470733a2f2f7261696c742e6f72672f696d616765732f6c6f676f2d6461726b2e737667)

 [![Travis CI](https://camo.githubusercontent.com/e0e5fd004400af4cc3d91c24d261122564d4eabc0ed0e95707b8f125218558f1/68747470733a2f2f7472617669732d63692e6f72672f7261696c742f646973636f766572792e7376673f6272616e63683d312e342e78)](https://travis-ci.org/railt/discovery) [![](https://camo.githubusercontent.com/b9e3c50ddde38ae537f38250d8b1cade6ed461a8c31892c0ec041b8bfefebc45/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f38323239373636633233343161316332663139322f746573745f636f766572616765)](https://codeclimate.com/github/railt/discovery/test_coverage) [![](https://camo.githubusercontent.com/e1941b862c5c7467e55346538478da990b9ed45933ea529cdb40cf881512e629/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f38323239373636633233343161316332663139322f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/railt/discovery/maintainability)

 [![PHP 7.1+](https://camo.githubusercontent.com/82f44fe3f392d956a0a6c330c62d48cfd37cc0fb6e21c39dad8f86c6c356dd30/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372e312b2d3666346361352e737667)](https://packagist.org/packages/railt/discovery) [![railt.org](https://camo.githubusercontent.com/e454d7e2800bf9ae8d0c4373f3312eb36201bb6987a75cf26c7afb56c121d2f3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6f6666696369616c2d736974652d3666346361352e737667)](https://railt.org) [![Discord](https://camo.githubusercontent.com/138a9e4e12a3ce4d76600b77fb52ee35a53342b8abaae49177c4db37f194465a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646973636f72642d636861742d3666346361352e737667)](https://discord.gg/ND7SpD4) [![Latest Stable Version](https://camo.githubusercontent.com/d356d282e4e45aaca2b2e200c1e7e7e9c590fab27e274ace975510f09447cad0/68747470733a2f2f706f7365722e707567782e6f72672f7261696c742f646973636f766572792f76657273696f6e)](https://packagist.org/packages/railt/discovery) [![Total Downloads](https://camo.githubusercontent.com/112369b395d2f909f28b24ebc6ef50682a44063bd3c0efaf765571399ad77f8d/68747470733a2f2f706f7365722e707567782e6f72672f7261696c742f646973636f766572792f646f776e6c6f616473)](https://packagist.org/packages/railt/discovery) [![License MIT](https://camo.githubusercontent.com/4e678e00f17eaf07f0c58d26a37177c77ee5f4d99496865f69079acfc3f03b85/68747470733a2f2f706f7365722e707567782e6f72672f7261696c742f646973636f766572792f6c6963656e7365)](https://raw.githubusercontent.com/railt/discovery/1.4.x/LICENSE.md)

> This package is **deprecated**.

Discovery
=========

[](#discovery)

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

[](#installation)

- Install package using composer.

```
composer require railt/discovery
```

- Add discovering event into your `composer.json`.

```
{
    "scripts": {
         "post-autoload-dump": [
             "Railt\\Discovery\\Manifest::discover"
         ]
     }
}
```

Usage
-----

[](#usage)

Discovery provides the ability to implement a cross-package configuration using `composer.json`.

In order to access the configuration group, you must specify the key name in the `extra` section:

```
{
    "extra": {
        "discovery": ["your-key"]
    }
}
```

Values Export
-------------

[](#values-export)

Any group that is listed inside the `{"extra": {"discovery": ...}}` section will be available, exported and readable.

```
{
    "extra": {
        "discovery": ["example-2"],
        "example-1": "value", // This section will be IGNORED
        "example-2": "value" // Only this section will be exported
    }
}
```

Reading Exported Values
-----------------------

[](#reading-exported-values)

After updating the composer dependencies, an object with the specified configs will be formed. In order to further read this data - you need to use the `Discovery` class.

```
{
    "extra": {
        "discovery": ["config"],
        "config": {
            "commands": [
                "ExampleCommand1",
                "ExampleCommand2"
            ]
        }
    }
}
```

```
