Download the PHP package timdev/typed-config without Composer

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

timdev/typed-config

What's This?

A small library to provide strictly typed access to data in an array, intended for use with a nested array of application configuration data. Nested values are dereferenced with dotted strings.

Usage

Install

Install this package with composer:

Usage

In a nutshell:

Assumptions and Design

In order to use this library effectively, it's important to understand its design and the assumptions that inform that design.

Assumption: All valid configuration values are defined

As demonstrated in example above, client code attempting to access an undefined value will throw. Our opinion is that a library or application should ship a complete default configuration. This is always a win for users. This design means that users are alerted early when they try to access an invalid key due to a typo or transcription error.

If you think you need an optional configuration parameter, you should instead provide a default such as null or perhaps [].

Design: Relies on PHP's assert()

assert is a language construct with a very useful mechanism: they are optimized out in production. This library uses assert() to type-check your configuration values before they're returned from the various accessor-methods.

If you're unfamiliar with the configuration values that affect how assert works, you should review the documentation and your environment's configuration before using this library. The short version is that you'll want to ensure that assert.exception = 1 and zend.assertion = 1 in your development and testing environments.

Because this library depends on assert(), the type checks are optimized away in production environments (where zend.assertion = 0). This reduces some overhead but means that configuration access that would throw an AssertionError in development will instead:

  1. Throw a TypeError, or
  2. Not throw anything, in the case of a hash/list mismatch.

Motivation

We developed this while building an application with mezzio, where configuration data are generally pulled from an array. Arrays are nice, but often cause you to have to:

  1. Code defensively whenever you pull some value from your $config array.
  2. Add assertions or comments to let your static analyzer of choice figure out what is happening.

This library is an attempt to improve that situation.

Alternatives

There are other libraries that approach the problem from different perspectives.

selective-php/config takes a similar approach in that it provides strictly typed methods to fetch (possibly nullable) values. Unlike this library, it enforces types by casting values as it returns them. We take a more strict posture, and consider mismatched types to be an error in the software. Its nullable-typed methods return null if a config key is not defined, while we consider that to be an error as well.

setbased/typed-config is also similar. Like the previously discussed library, it will attempt to cast whatever it finds in the config data to the required type, and is more permissive about undefined config keys than this library is.

league/config takes an even more strict approach by helping you define a strict schema for your configuration data. We really like that approach (at least for some contexts), but are somewhat bewildered that it provides a single get(string $key): mixed accessor.

To Do


All versions of typed-config with dependencies

PHP Build Version
Package Version
Requires php Version ~7.4.0 || ^8
symfony/polyfill-php80 Version ^1.23
symfony/polyfill-php81 Version ^1.23
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 timdev/typed-config contains the following files

Loading the files please wait ....