rpodwika/yaml-config-service-provider

Based on deralex/YamlConfigServiceProvider YAML service provider for silex ~2.0 and symfony/yaml 3.~

1.0.1 2016-09-15 13:14 UTC

This package is auto-updated.

Last update: 2024-04-23 09:10:52 UTC


README

Usage

<?php

require_once __DIR__.'/../vendor/autoload.php';

$app = new Silex\Application();

$app->register(new Rpodwika\Silex\YamlConfigServiceProvider(PATH_TO_CONFIG_FILE));

echo $app['config']['database']['driver'];
...

where PATH_TO_CONFIG_FILE is location of YML file with configuration for example __DIR__ . "/../app/config/parameters.yml"

considering following directory structure:

  • app
    • config
      • parameters.yml
  • web
    • index.php

parameters.yml

    database:
          driver :  'pdo_mysql'
          dbhost :  'localhost'
          dbname :  'mydbname'
          user :    'root'
          password : ''

Installation

Add to composer.json

"require": {
    "rpodwika/yaml-config-service-provider": "dev-master"
}

or run command composer require rpodwika/yaml-config-service-provider

This bundle is inspired on deralex/YamlConfigServiceProvider

Licence

GPL 3.0