Download the PHP package jenson/convict without Composer

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

php-convict

This is a php implementation of node-convict, with some additional features and some features yet to be implemented.

Install

`

TODO

This is far from a completed library yet, even if it works.

The following needs to be done:

Usage

First define a scheme and then get and set values from that scheme:

Can be started with

API

Constructor

Parameters

filename | json-string Scheme The scheme to load, either as a filename or as a JSON string.

Array Options Defaults to an empty array. Valid options:

nohelp => true Turn of the automatic command line help.

Throws

Throws an \Exception if the scheme is invalid.

Convict->get

Parameters

string key Defaults to empty. Use a dot notation to address configuration values.

Returns

null If the key does not exist mixed If the key points to a leaf then that value is returned. If the key points to a part of the configuration tree then that sub-part is returned. An empty key returns the entire config tree.

Throws

Should not throw an exception.

Convict->set

Parameters

string key The key to set the value for. Use a dot notation to address configuration values. If the key doesnt exist then it will be created. mixed value The value to set

Returns

Does not return anything

Throws

Should not throw an exception.

Note

The values set are not persisted in any way. Use Convict->writeFile to save them.

Only the leafs can carry values, and if a new leaf is created then the value on the previous position will be discarded. Example:

``

Convict->addFormat

Set a custom format for the validator to use. Just use the class name in the format field in the scheme. Case insensitive.

Parameters

Convict\Validator\Validator format An instance of a class implementing the Validator interface.

Returns

Does not return anything

Throws

Should not throw an exception.

The Validator interface

validate ($key, $value) Should throw a Validator\ValidationException for invalid values. coerce ($value) Should return a value that has been formated to fit the application.

Convict->validate

Parameters

No parameters

Returns

Does not return any value

Throws

Will throw either a Validator\ValidationException or an \Exception depending on the circumstances.

Note

For convenience sake this function will set the uncaught exception handler function to handle the events it throws out. After the validation it will restore the previous exception handler.

Convict->loadFile

Parameters

Array | filename files Will go through all the filenames in the array and load them in order. Also accepts a single file name.

Returns

Does not return any value.

Throws

Does not throw any exception.

Convict->loadConfigJson

Parameters

Array | string jsons Will go through all the JSON strings and load them to the config as if the were loaded from a file. Can also handle single JSON entries.

Returns

Does not return anything

Throws

Nope.

The config file

A config file is loaded with

and a file that matches the scheme above can look like this

It is not fully json5 compatible, but comments are allowed (and encouraged).

The library can write a config file with

and will use the special about field in the scheme and all the doc fileds as comments.

Precedence

The rules of precedence are:

  1. Command line argument
  2. Environment variable
  3. Configuration file value
  4. Default value
  5. Throw an exception because we dont know what to do.

The scheme

Format

Validate the value with this format. Does not apply to runtime config::set's.

Supported formats:

You can add a new format at runtime through config::addFormat(Convict\Validator\Validator).

Arg

Look for this as a long form command argument. Uses getopt in the background, so add :: afterwards to make it optional.

Shortarg

Same as arg, but governs the short form (-X etc).

Env

Load from this environment variable.

Default

Use this value if nothing else comes along. Note that this will also be subjected to the format rules. This is optional, but if it is omitted and not added at runtime then an exception will be thrown when the config is instanciated.

Autogenerated help

Per default the config listens for -h and --help and will print a help message and exit. This can be turned of by passing the option "nohelp" => true.

``


All versions of convict with dependencies

PHP Build Version
Package Version
No informations.
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 jenson/convict contains the following files

Loading the files please wait ....