Skip to content

Instantly share code, notes, and snippets.

@peterjmit
Created March 30, 2012 11:21
Show Gist options
  • Save peterjmit/2250882 to your computer and use it in GitHub Desktop.
Save peterjmit/2250882 to your computer and use it in GitHub Desktop.
Global Symfony 2 Config without Config Parsing
# app/config/config_dev.yml
imports:
- { resource: config.yml }
framework:
# ...
web_profiler:
# ...
monolog:
# ...
assetic:
# ...
services:
# ...
parameters:
test.foo_array:
- { bar: value }
- { baz: value }
# src/Vendor/SomeBundle/Resources/config/services.yml
parameters:
# ...
services:
some_service:
# ...
arguments: [ %test.foo_array% ]
<?php
// src/Vendor/SomeBundle/Controller/SomeController.php
namespace Vendor\SomeBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller,
Symfony\Component\HttpFoundation\Request;
class SomeController extends Controller
{
public function fooAction()
{
$configArray = $this->container->getParameter('test.foo_array');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment