Download the PHP package carstenwindler/config without Composer

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

Latest Stable Version Build Status Minimum PHP Version License Total Downloads Scrutinizer Code Quality Code Coverage

About this package

Drop dead simple config package. Use it to bootstrap and access your configuration settings within your PHP application.

Slim, tested, works from PHP 7.3 upwards, and won't add any other dependencies to your codebase.

Requirements

Yep, that's it.

Installation

Via composer:

Why one more config package?

This package started as even simpler config class I added to a project once, and I kept using and improving it. Add some point, I decided to publish it as a package. There are good reasons for using other (bigger) packages for sure, but if you just need a configuration class that won't add any overhead to your project, it might be the right choice.

Cascading configs

The basic idea behind this Config package is the idea of "Cascading configs": you don't lpad the whole config at once, but build it up step by step.

You start with a "main configuration" which is contains basic configuration for all purposes, and then you add more (or overwrite previous) configuration depending on the environment you are. For example, on the local development environment you might want to use different versions of web services than on production.

Simple "array dot" notation

Unbeatable fast and easy is to use the "array dot" notation to address configuration items (e.g. ).

This has a big drawback though - the config is addressed using strings, which can lead to "rotting configuration" easily. Checkout below "Strict mode" section on how to fight that.

Usage

Initialization

There are 3 ways to set the configuration.

Load from file

Often enough, application configurations are simply stored in files, so this is the standard use case for Config.

Config uses PHP arrays as the only configuration format. To store arrays in files, you could e.g. use this notation:

Why just PHP arrays? Because they are simple, powerful, fast and supported out of the box. If you want or need to store your configurations in e.g. YAML format, you would need to add that functionality yourself by simply loading the YAML, convert it to an array and pass it over to Config.

Load from array

Typically you would use this way to setup the config during tests.

Set config directly

Typically you would use this way to setup the config during tests.

Retrieve and manipulate configuration during runtime

You can specify defaults in case the desired value does not exist:

Otherwise the return value will be null

See section "Strict mode" below for more options!

Strict mode

To avoid using config items in your code base which do not exist, you can turn on the "strict mode". In case a desired value does not exist, Config will throw an exception instead of returning null.

This can reveal problems in your configuration, however you should not enable it on production environments. It is meant to be used locally or during CI builds.

Troubleshooting

  1. What, no yml support out of the box? Are you kidding? No. Yml is a great format, but you might not use it in your project. You can still use YAML loaders like mustangostang/spyc to load the yml as array and pass it over to Config.

TODO

  1. Align function names (e.g. add() and mergeConfig() do basically the same, just from different sources)

All versions of config with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3 || ^8.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 carstenwindler/config contains the following files

Loading the files please wait ....