Download the PHP package weew/config without Composer

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

Configuration made simple

Build Status Code Quality Test Coverage Version Licence

Table of contents

Installation

composer require weew/config

Loading configurations

The config loader is responsible for loading of the configuration files. All you have to do is to provide a location(file or directory) where it can find your configs. It will scan the locations(s) for configuration files and return you a config object.

Accessing configurations

You can easily access config values by the config key.

Configuration formats

Following formats are supported out of the box.

Plain PHP format example:

INI format example:

YAML format example:

Json format example:

References

You can always reference to other config values from within a config file. To create a reference, simple wrap a config key with curly braces {config.key}`.

You can even reference whole config blocks.

Now when you access the reference value you will get "bar" in return. Keep in mind that references are interpolated at access time (when you call $config->get()). This means that if you change a config value, everyone who references it will receive it's updated value and not the old one.

Runtime config

Sometimes you might want to apply runtime config from an array or similar that also has a higher priority as the config loaded from the filesystem.

Environments

Often you want to split your configurations in multiple files or directories and load them depending on your current environment. This can be achieved trough the environment settings.

Setting an environment

Out of the box it comes with support for dev, test and prod environments. Custom environments can be added on the fly.

How it works

To understand how environments detection works, lets take a look at this directory structure:

In the test environment only the "test" directory and it's contents, "config_test.php" and "config.php" will be loaded. In the prod environment however, it will load only the "prod" directory, "config_prod.php" and "config.php".

Files and folders that have been added to the config loader will be loaded in the order of registration. Inside directories, files are loaded alphabetically.

Adding custom environments

To create your own environments you'll have to register a new rule on the environment detector. The first argument is the name of the environment and the second is an array of masks.

Below is a list of some files and directories that would match the integration environment:

This files will not match:

As delimiter you can use any of this characters: ._+:-.

Ignoring files

This files are ignored by default:

You may specify custom rules to ignore certain files:

Extending

Config loader provides you multiple extension points to alter its behaviour and functionality.

Custom config drivers

Adding your own drivers is very easy. All you have to do is to implement the IConfigDriver interface and pass an instance of the driver to the config loader. You can have multiple active drivers at the same time.

Custom environment detector

You can replace the default environment detector with your own. Just create a new detector which implements the IEnvironmentDetector interface and pass it to the config loader. Also take a look on how to create your own environments.


All versions of config with dependencies

PHP Build Version
Package Version
Requires weew/helpers-filesystem Version ^1.0
weew/helpers-array Version ^1.0
symfony/yaml Version ^3.0
weew/contracts Version ^1.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 weew/config contains the following files

Loading the files please wait ....