Download the PHP package yosymfony/config-serviceprovider without Composer

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

Config ServiceProvider for Silex

A configuration ServiceProvider for Silex based on Symfony Config component with support for YAML, TOML (0.2.0) and JSON.

Build Status Latest Stable Version Scrutinizer Quality Score Total Downloads

Installation

Use Composer to install Yosyfmony ConfigServiceProvider package:

Add the following to your composer.json and run composer update.

"require": {
    "yosymfony/config-serviceprovider": "1.2-dev"
}

More informations about the package on Packagist.

Usage

Register the ServiceProvider:

$app->register(new ConfigServiceProvider());

You can set a collection of locations where it should look for files and reference it only with the file's name

$app->register(new ConfigServiceProvider(array(
    __dir__.'/config',
    '/var/www/general-config'
)));

Load a configuration file:

$repository = $app['configuration']->load('user.yml');

// or load with absolute path:
$repository = $app['configuration']->load('/var/config/user1.yml');

.dist files

This library have support to .dist files. The location of a file follow the next hierachy:

Load inline configuration:

use Yosymfony\Silex\ConfigServiceProvider\Config;

$repository = $app['configuration']->load('server: "mail.yourname.com"', Config::TYPE_YAML);
// or
$repository = $app['configuration']->load('server = "mail.yourname.com"', Config::TYPE_TOML);

Repository

The configuration file is loaded to a repository. A repository is a wrapper with array access interface that supply methods for validating configurations values and merge with other repositories.

$repository->get('name', 'noname'); // If 'name' not exists return 'noname'
$repository['name']; // Get the element in 'name' key

Validating configurations

The values and the structure can be validated using a definition class from Symfony Config component. For example, for this configuratión file:

# Yaml file
port: 25
server: "mail.yourname.com"

you can create the below definition:

use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;

class MyConfigDefinitions implements ConfigurationInterface
{
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();
        $rootNode = $treeBuilder->root(0);

        $rootNode->children()
            ->integerNode('port')
                ->end()
            ->scalarNode('server')
                ->end()
        ->end();

        return $treeBuilder;
    }
}

and check your repository: $repository->validateWith(new MyConfigDefinitions()); An exception will be thrown if any definition constraints are violated.

Operations

The operation mergeWith was deprecated since version 1.2.0 and replaced by union method.

Unions

You can get the union of repository A with other B with C as result: $resultC = $repositoryA->union($repositoryB);. The values of $repositoryB have less priority than $repositoryA.

Intersections

You can get the intersection of repository A with other B with C as result: $resultC = $repositoryA->intersection($repositoryB);. The values of $repositoryB have less priority than $repositoryA.

Create a blank repository

Create a blank repository is too easy. You only need create a instance of ConfigRepository and use the array interface or set method to insert new values:

use Yosymfony\Silex\ConfigServiceProvider\ConfigRepository;

//...

$repository = new ConfigRepository();
$repository->set('key1', 'value1');
// or
$repository['key1'] = 'value1';

and the next, you merge with others or validate it.

Unit tests

You can run the unit tests with the following command:

$ cd your-path/vendor/yosymfony/config-serviceprovider
$ composer.phar install --dev
$ phpunit

All versions of config-serviceprovider with dependencies

PHP Build Version
Package Version
Requires silex/silex Version ~1.0
symfony/config Version 2.4.*@dev
yosymfony/toml Version 0.2.*@dev
symfony/yaml Version 2.4.*@dev
php Version >=5.3.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 yosymfony/config-serviceprovider contains the following files

Loading the files please wait ....