Download the PHP package loilo/simple-config without Composer

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

Simple Config

Tests Version on packagist.org

Simple persistent configuration for your app or module, heavily inspired by Sindre Sorhus' conf package.

Installation

Usage

Methods

There are four methods on the Config object that you may use to work with the data store — get, set, has and delete:

Static Access

Since app-wide configuration usually only ever requires one Config instance, you may not want to manually pass around that instance everywhere.

In most frameworks, a dependency injection container solves this task for you. However, for cases where no such mechanism is set up, this package provides the StaticConfig class.

It's an abstract class which you can extend in your project. The only thing you have to provide is a method to actually create a Config object. The simplest possible implementation therefore looks like this:

Now you can work with your configuration like this:

Options

The Config object can be initialized with an associative array of options documented below.

defaults

Type: array
Default: null

Default values for config items

Note 1: Default values are applied with shallow (not recursive) merging: only missing top level options in the data are supplemented by defaults.

Note 2: Defaults are never written to the config file so if you change your app's defaults and users have not overridden them explicitly, they will also change for all users.

schema

Type: array
Default: null

A JSON Schema to validate your config data. JSON Schema draft-07 is used as far as it's supported by the underlying validator package.

Note 1: Your top-level schema definition is enforced to be of "type": "object".

Note 2: Default values defined in your schema are applied during validation, but are not returned when requested via Config::get(). This is a limitation of the underlying validator, as there's currently no JSON schema validator in PHP that applies default values to validated data and then allows access to them.

Note 3: If your schema defines any mandatory top-level fields, you'll need to provide defaults that satisfy the schema. This avoids schema violation errors when initializing an empty configuration.

configName

Type: string
Default: "config"

Name of the config file (without extension).

Useful if you need multiple config files for your app or module (e.g. different config files between two major versions).

projectName

Type: string
Default: The name field in the composer.json closest to where new Config() is called.

You only need to specify this if you don't have a composer.json file in your project.

configDir

Type: string
Default: System default user config directory

The place where your config file is stored. You may override this to store configuration locally in your app's folder.

Note: If you define this, the projectName option will be ignored.

format

Type: array

Settings regarding the configuration format. This is an associative array with the following possible keys:

password

Type: string
Default: null

A password to encrypt/decrypt the configuration file with. This can secure sensitive data, however it's naturally only as secure as your way of managing the password itself.

Note: If you encrypt the configuration with a password, the config file will be saved in a binary format and the format.extension option will be ignored.

dotNotation

Type: boolean
Default: true

Whether to access options by dot notation.

clearInvalidConfig

Type: boolean
Default: true

If set to true, the configuration is cleared if reading it raises an exception of any sort:

Exception Cause
IOException The config file exists but could not be read.
EnvironmentIsBrokenException
WrongKeyOrModifiedCiphertextException
File decryption failed (when using a password).
DeserializationException Deserialization failed (e.g. if the deserialization function changed or if someone or something meddled with the file).
InvalidConfigException The configuration is invalid according to the schema.

Enabling this option is a good default, as the config file is not intended to be hand-edited, so this usually means the config is corrupt and there's nothing your app can do about it anyway. However, if you let the user edit the config file directly, mistakes might happen and it could be useful to throw an error when the config is invalid instead of clearing it.

Disabling this option will cause the exceptions listed above to be re-thrown and handled manually.


All versions of simple-config with dependencies

PHP Build Version
Package Version
Requires php Version >= 7.1
ext-json Version *
loilo/x-filesystem Version ^1.0
loilo/find-up Version ^1.0
loilo/storage-paths Version ^1.0
loilo/traceback Version ^1.0
webmozart/path-util Version ^2.3
justinrainbow/json-schema Version ^5.2
adbario/php-dot-notation Version ^2.2
symfony/var-dumper Version ^4.3
symfony/yaml Version ^4.3
defuse/php-encryption Version ^2.2
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 loilo/simple-config contains the following files

Loading the files please wait ....