Download the PHP package consolidation/config without Composer

On this page you can find all versions of the php package consolidation/config. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package config

Consolidation\Config

Manage configuration for a commandline tool.

ci scrutinizer codecov license

This component is designed to provide the components needed to manage configuration options from different sources, including:

Symfony Console is used to provide the framework for the commandline tool, and the Symfony Configuration component is used to load and merge configuration files. This project provides the glue that binds the components together in an easy-to-use package.

If your goal is to be able to quickly write configurable commandline tools, you might want to consider using Robo as a Framework, as the work for setting up this component is already done in that project. Consolidation/Config may be used with any Symfony Console application, though.

Component Status

In use in Robo, Terminus and Drush.

Motivation

Provide a simple Config class that can be injected where needed to provide configuration values in non-command classes, and make configuration settings a no-op for command classes by automatically initializing the Input object from configuration as needed.

Configuration File Usage

Configuration files are simple hierarchical yaml files.

Providing Command Options

Command options are defined by creating an entry for each command name under the command: section of the configuration file. The options for the command should be defined within an options: section. For example, to set a configuration value red for the option --color in the example command:

If a command name contains a :, then each section of the command name defines another level of hierarchy in the command option configuration. For example, to set a configuration value George for the option --name of the command my:foo:

Furthermore, every level of the command name hierarchy may contain options. For example, to define a configuration value for the option --dir for any command that begins with my::

Providing Global Options

If your Symfony Console application defines global options, like so (from a method in an extension of the Application class):

Default values for global options can then be declared in the global options section:

If this is done, then global option values set on the command line will be used to alter the value of the configuration item at runtime. For example, $config->get('options.simulate') will return false when the --simulate global option is not used, and will return true when it is.

See the section "Set Up Command Option Configuration Injection", below, for instructions on how to enable this setup.

Configuration Value Substitution

It is possible to define values in a configuration file that will be substituted in wherever used. For example:

grasmash/yaml-expander is used to provide this capability.

API Usage

The easiest way to utilize the capabilities of this project is to use Robo as a framework to create your commandline tools. Using Robo is optional, though, as this project will work with any Symfony Console application.

Load Configuration Files with Provided Loader

Consolidation/config includes a built-in yaml loader / processor. To use it directly, use a YamlConfigLoader to load each of your configuration files, and a ConfigProcessor to merge them together. Then, export the result from the configuration processor, and import it into a Config object.

Set Up Command Option Configuration Injection

The command option configuration feature described above in the section Providing Command Options is provided via a configuration injection class. All that you need to do to use this feature as attach this object to your Symfony Console application's event dispatcher:

Get Configuration Values

If you have a configuration file that looks like this:

Then you can fetch the value of the configuration option c via:

dflydev/dot-access-data is leveraged to provide this capability.

Interpolation

Interpolation allows configuration values to be injected into a string with tokens. The tokens are used as keys that are looked up in the config object; the resulting configuration values will be used to replace the tokens in the provided string.

For example, using the same configuration file shown above:

In this example, the $result string would be:

Configuration Overlays

Optionally, you may use the ConfigOverlay class to combine multiple configuration objects implamenting ConfigInterface into a single, prioritized configuration object. It is not necessary to use a configuration overlay; if your only goal is to merge configuration from multiple files, you may follow the example above to extend a processor with multiple configuration files, and then import the result into a single configuration object. This will cause newer configuration items to overwrite any existing values stored under the same key.

A configuration overlay can achieve the same end result without overwriting any config values. The advantage of doing this is that different configuration overlays could be used to create separate "views" on different collections of configuration. A configuration overlay is also useful if you wish to temporarily override some configuration values, and then put things back the way they were by removing the overlay.

The first call to $configOverlay->get('key'), above, will return the value from key in $config2, if it exists, or from $config1 otherwise. The second call to the same function, after $config2 is removed, will only consider configuration values stored in $config1.

External Examples

Load Configuration Files with Symfony/Config

The Symfony Config component provides the capability to locate configuration file, load them from either YAML or XML sources, and validate that they match a certain defined schema. Classes to find configuration files are also available.

If these features are needed, the results from Symfony\Component\Config\Definition\Processor::processConfiguration() may be provided directly to the Consolidation\Config\Config::import() method.

Use Configuration to Call Setter Methods

Robo provides a facility for configuration files to define default values for task setter methods. This is done via the ConfigForSetters::apply() method.

The configClassIdentifier method converts \-separated class and namespace names into .-separated identifiers; it is provided by ConfigAwareTrait:

A similar pattern may be used in other applications that may wish to inject values into objects using their setter methods.

Comparison to Existing Solutions

Drush has an existing procedural mechanism for loading configuration values from multiple files, and overlaying the results in priority order. Command-specific options from configuration files and site aliases may also be applied.


All versions of config with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1.3
dflydev/dot-access-data Version ^1.1.0 || ^2 || ^3
grasmash/expander Version ^2.0.1 || ^3
symfony/event-dispatcher Version ^4 || ^5 || ^6
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package consolidation/config contains the following files

Loading the files please wait ....