Download the PHP package corex/config without Composer

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

Config Component

license build Code Coverage PHPStan Level

Breaking changes - this package has been rewritten from scratch to be more strict and flexible to use. Adapters are supported in favor of loaders. Breaking changes can be found in CHANGELOG.

Getting configuration values works by creating instance of Config::class and use methods to get values. Multiple adapters are supported.

Example:


A method section() is added for convenience when section and rest of key is separated eg. section = "actor" and key = "name".

Example of using section():


A method getConfigClassObject() is added for getting array and pass to config-class on constructor.

Example of using getConfigClassObject():

ConfigFactory

A ConfigFactory exists to make it easier to create instances of Config::class.

Example:

The above example exposes 3 adapters ServerAdapter, EnvAdapter and ProjectConfigArrayFileAdapter.

From above example, when getting value, the process is following.

Based on various methods to get values, a null is returned or an exception is thrown.

More methods exists, but in the situation where they does not fit in, instantiate Config::class with your own order of adapters.

Keys

Every key must be specified as dot notation e.g. "actor.name".

"_" and "-" will not be treated as separators.

When using ServerAdapter and EnvAdapter, the key will be converted to shoutcase e.g. ACTOR_NAME. This makes it easy to override values in e.g. cloud environments.

Key object is passed to adapter and multiple methods exists to get key in various formats. Use custom() to build your own.

Config

Various methods exists on config-class for getting values in correct format. There exists methods for getting specific type with or without null eg. "getString()" or "getStringOrNull()" . Following types are supported: string, int, bool translated-bool, double, array, list.

For all type methods, value from adapters will be checked if they are correct type, otherwise an exception is thrown.

"translated-bool" translates/converts following values to boolean.

Values for true : ['true', true, 'yes', 'on', 1, '1'].

Values for false : ['false', false, 'no', 'off', 0, '0'].

"list" means an array where keys are numeric keys 0..n.

Adapters

It is possible to write your own adapter by extending AbstractAdapter or implementing AdapterInterface.

Following standard adapters expose arrays as the basis for configuration values.

ArrayAdapter

Serve simple array.

EnvAdapter

Serve $_ENV global array.

ServerAdapter

Serve $_SERVER global array.

ArrayFileAdapter

Serve php array files outside project root.

ProjectPathArrayFileAdapter - Serve

Serve php array files in project root from relative directory.

ProjectConfigArrayFileAdapter

Serve php array files in project root from relative directory called "config".

Array files.

Example of an array-file.

Name of file "bond.php".

These type of files can be loaded via ArrayFileAdapter, ProjectPathArrayFileAdapter and ProjectConfigArrayFileAdapter.

Example of a config-key: "bond.actor1.firstname" which will return "Roger".

First section of key "bond" indicates the section and on these adapters the filename.


All versions of config with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
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 corex/config contains the following files

Loading the files please wait ....