Download the PHP package tomphp/config-service-provider without Composer

On this page you can find all versions of the php package tomphp/config-service-provider. 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-service-provider

Container Configurator

Build Status Scrutinizer Code Quality Latest Stable Version Total Downloads Latest Unstable Version License

This package enables you to configure your application and the Dependency Injection Container (DIC) via config arrays or files. Currently, supported containers are:

Installation

Installation can be done easily using composer:

Example Usage

Reading Files From Disk

Instead of providing the config as an array, you can also provide a list of file pattern matches to the fromFiles function.

configFromFile(string $filename) reads config in from a single file.

configFromFiles(string $pattern) reads config from multiple files using globbing patterns.

Merging

The reader matches files in the order they are specified. As files are read their config is merged in; overwriting any matching keys.

Supported Formats

Currently .php and .json files are supported out of the box. PHP config files must return a PHP array.

.yaml and .yml files can be read when the package symfony/yaml is available. Run

to install it.

Application Configuration

All values in the config array are made accessible via the DIC with the keys separated by a separator (default: .) and prefixed with constant string (default: config).

Example

Accessing A Whole Sub-Array

Whole sub-arrays are also made available for cases where you want them instead of individual values.

Example

Configuring Services

Another feature is the ability to add services to your container via the config. By default, this is done by adding a services key under a di key in the config in the following format:

Service Aliases

You can create an alias to another service by using the service keyword instead of class:

Service Factories

If you require some addition additional logic when creating a service, you can define a Service Factory. A service factory is simply an invokable class which can take a list of arguments and returns the service instance.

Services are added to the container by using the factory key instead of the class key.

Example Config

Example Service Factory

Injecting The Container

In the rare case that you want to inject the container in as a dependency to one of your services, you can use Configurator::container() as the name of the injected dependency. This will only work in PHP config files, it's not available with YAML or JSON.

Configuring Inflectors

It is also possible to set up Inflectors by adding an inflectors key to the di section of the config.

Extra Settings

The behaviour of the Configurator can be adjusted by using the withSetting(string $name, $value method:

Available settings are:

Name Description Default
SETTING_PREFIX Sets prefix name for config value keys. config
SETTING_SEPARATOR Sets the separator for config key. .
SETTING_SERVICES_KEY Where the config for the services is. di.services
SETTING_INFLECTORS_KEY Where the config for the inflectors is. di.inflectors
SETTING_DEFAULT_SINGLETON_SERVICES Sets whether services are singleton by default. false

Advanced Customisation

Adding A Custom File Reader

You can create your own custom file reader by implementing the TomPHP\ContainerConfigurator\FileReader\FileReader interface. Once you have created it, you can use the withFileReader(string $extension, string $readerClassName) method to enable the it.

IMPORTANT: withFileReader() must be called before calling configFromFile() or configFromFiles()!

Adding A Custom Container Adapter

You can create your own container adapter so that you can configure other containers. This is done by implementing the TomPHP\ContainerConfigurator\FileReader\ContainerAdapter interface. Once you have created your adapter, you can use the withContainerAdapter(string $containerName, string $adapterName) method to enable the it:


All versions of config-service-provider with dependencies

PHP Build Version
Package Version
Requires php Version ^5.6|^7.0
beberlei/assert Version ^2.6
tomphp/exception-constructor-tools Version ^1.0.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 tomphp/config-service-provider contains the following files

Loading the files please wait ....