Download the PHP package phlak/config without Composer

On this page you can find all versions of the php package phlak/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

Join our Community Become a Sponsor One-time Donation
Latest Stable Version Total Downloads License

PHP library for simple configuration management -- Created by Chris Kankiewicz (@PHLAK)


Introduction

Config is a simple PHP configuration management library supporting multiple configuration file formats and an expressive API.

Supported file formats:

Requirements

Install with Composer

Initializing the Client

First, import Config:

Then instantiate the class:

Where $context is one of the following:

And $prefix is a string to be used as a key prefix for options of this Config object.

Configuration File Formats

PHP

A PHP configuration file must have the .php file extension, be a valid PHP file and and return a valid PHP array.

Example PHP file

INI

An INI configuration file must have the .ini file extension and be a valid INI file.

Example INI file

JSON

A JSON configuration file must have the .json file extension and contain a valid JSON object.

Example JSON file

TOML

A TOML configuration file must have the .toml file extension and be a valid TOML file.

Example TOML file

YAML

A YAML configuration file must have the .yaml file extension, be a valid YAML file.

Example YAML file

XML

A XML configuration file must have the .xml file extension and contain valid XML.

Example XML file

Usage

__construct

Create a new Config object.

$context
Raw array of configuration options or path to a configuration file or directory containing one or more configuration files
$prefix
A key under which the loaded config will be nested

Examples

Create a new Config object from a YAML file.

Create a new Config object from a directory of config files.

Create a new Config object from an array.


set

Store a config value with a specified key.

$key
Unique configuration option key
$value
Config item value

Example


get

Retrieve a configuration option via a provided key.

$key
Unique configuration option key
$value
Config item value

Examples

Define a default value to return if the option is not set.


has

Check for the existence of a configuration item.

$key
Unique configuration option key

Example


append

Append a value onto an existing array configuration option.

$key
Unique configuration option key
$value
Config item value

Example

Append baz to the tags config item array.


prepend

Prepend a value onto an existing array configuration option.

$key
Unique configuration option key
$value
Config item value

Example

Prepend baz to the tags config item array.


unset

Unset a configuration option via a provided key.

$key
Unique configuration option key

Example


load

Load configuration options from a file or directory.

$path
Path to configuration file or directory
$prefix
A key under which the loaded config will be nested
$override
Whether or not to override existing options with values from the loaded file

Examples

Load a single additional file.

Load an additional file with a prefix.

Load an additional file without overriding existing values.


merge

Merge another Config object into this one.

$config
Instance of Config
$override
Whether or not to override existing options with values from the merged config object

Examples

Merge $anotherConfig into $config and override values in $config with values from $anotherConfig.

Merge $anotherConfig into $config without overriding any values. Duplicate values in $anotherConfig will be lost.


split

Split a sub-array of configuration options into it's own Config object.

$key
Unique configuration option key

Example


toArray

Return the entire configuration as an array.

Example


Troubleshooting

For general help and support join our GitHub Discussion or reach out on Twitter.

Please report bugs to the GitHub Issue Tracker.

Copyright

This project is liscensed under the MIT License.


All versions of config with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0 || ^8.1 || ^8.2
symfony/yaml Version ^5.0 || ^6.0
yosymfony/toml Version ^1.0
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 phlak/config contains the following files

Loading the files please wait ....