This site has been archived. To learn more about our current products Ibexa Content, Ibexa Experience, Ibexa Commerce head over to the Ibexa Developer Portal

eZ Community » Forums » eZ Publish 5 Platform » Read configuration files

Read configuration files

Read configuration files

Wednesday 11 September 2013 3:54:29 pm - 2 replies


this is really a Symfony question but I really can't figure out a simple way to read configuration files. For example, if I have a myconf.yml file like this:



    max: 75

    min: 18

and I want to be able to write (in a controller or service):

$config = ?? # <== what goes here ?

if ($userAge < $config->user->age->min) {

or maybe "if ($userAge < $config->get("user.age.min"blunk.gif Emoticon) {"

  $status = 'too young';


I have written my own quick and dirty service using Symfony\Component\Yaml\Parser but I wonder if there's something that does this out of the box. It seems a fairly obvious feature.

I have read "How to expose a Semantic Configuration for a Bundle" at but that seems a really complicated way of doing something really simple.



Thursday 12 September 2013 10:00:32 am


It's easy the Symfony way:

$minAgeConfig = $this->container->getParameter('user.age.min');

You might need to put the "user" config under "parameters".

Hope that helps!

Modified on Thursday 12 September 2013 10:01:03 am by R E

Thursday 12 September 2013 10:31:16 am

Hi Francesco

Ryad-Marcel is right. Most symfony config are reachable from the service container. However, when you define services, the best practice is to inject the parameters, not the container (see Symfony doc on service container parameters).

That being said, eZ Publish introduces a more dynamic system, siteaccess aware which is called ConfigResolver. This identifier of this service is ezpublish.config.resolver.


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from