Skip to content

Instantly share code, notes, and snippets.

@faizalpribadi
Created December 19, 2013 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save faizalpribadi/8034172 to your computer and use it in GitHub Desktop.
Save faizalpribadi/8034172 to your computer and use it in GitHub Desktop.
Bootstrapping & Create Own Configuration With Yaml ( Simply & Magic )
# yaml (http://yaml.org/spec/)
services:
configuration:
class: Configuration
calls:
-
- setting
-
- name: Faizal Pribadi
<?php
class Configuration
{
public function setting(array $settings)
{
var_dump($settings);
}
}
<?php
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\Config\FileLocator;
$builder = new ContainerBuilder();
$loader = new YamlFileLoader($builder, new FileLocator(__DIR__));
$loader->load('config.yml');
$test = $builder->get('configuration');
// Result
// array(1) {
// ' name' =>
// string(14) "Faizal Pribadi"
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment