Download the PHP package freezemage0/config without Composer

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

freezemage0/config is a library that provides an easy way to read and create configuration files. Supports .json, .ini and .php formats.

Installation

You can install this package using composer: composer require freezemage0/config

Usage

ConfigFactory

ConfigFactory automatically resolves the Importer and Exporter for the configuration. The resolving is based on file extension.

Usage example:

Creation of configuration object

The returned config file will be ready to decode and encode JSON data from config.json file.

Registering of custom Importers and Exporters

You may want to make your own importer or exporter. In that case you can register them using ConfigFactory::registerImporter() and ConfigFactory::registerExporter() methods. All custom importers and exporters MUST implement ImporterInterface and ExporterInterface respectively.

ImmutableConfig

Basic configuration class, which provides methods to read, set and save configurations. Instances of this class are immutable, meaning that any call to set() will return a new instance.

Basic usage:

Retrieving specific value by key can be done by calling ImmutableConfig::get() method. Retrieving all configuration values can be done by calling ImmutableConfig::getConfig() method. The configuration is loaded on-demand.

Key chaining

The get/set methods of ImmutableConfig support key chaining. It means that you can use dot (.) to concatenate the nested keys of configuration in order to get the nested value. Here is the configuration:

You can retrieve username for database connection using the following call:

Feature management

Local management

To disable/enable key chaining for current instance of ImmutableConfig, call ImmutableConfig->disableKeyChaining().

Global management

Example on how to disable/enable key chaining for all instances that will be created by ConfigFactory object:

Saving

You can also create/edit configuration using ImmutableConfig::set() method. When you set value, you get a new instance of ImmutableConfig with a new key => value pair. This is done in order to preserve immutability of the original configuration until you are ready to save it.

If you create a new instance of ImmutableConfig with no file to import, then it will be created. If the Exporter within ImmutableConfig doesn't have filename, then it will be generated based on configuration content. The same configuration leads to the same filename. The generated configuration name can be retrieved via ImmutableConfig->getExporter()->getFilename()

Section extraction

You can extract a section from the config and work with it as a separate instance of ImmutableConfig. The extracted ImmutableConfig section will behave exactly as if it was root section. Be wary that calling ImmutableConfig->save() will rewrite the contents of original config file, unless you do something like the following:

Configuration converting

You may want to convert configuration from .json to .php format. The following example does exactly that:

Precautions

Nested sections are not supported for IniExporter (as they are generally not support by anyone).\ Calling IniExporter->export() with nested section will throw UnsupportedNestingException.


All versions of config with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4
ext-json Version *
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 freezemage0/config contains the following files

Loading the files please wait ....