0

My goal is to add to a new Symfony 4.4 project an extra config file to define some behavior of the system. It could be anything, like, pancakes.yaml:

pancakes:
    enablePancakes: false

I wish to know how can I load that config file. find a way to read its parameters and values to change some custom behavior the system might have but honestly I think I'm not smart enough to understand what the documentation says.

For now it could be anything, like printing the configuration file values, for now I only need to know how to load it.

yivi
  • 42,438
  • 18
  • 116
  • 138
H3lltronik
  • 562
  • 8
  • 26
  • 3
    You would typically make this a [parameter](https://symfony.com/doc/current/configuration.html#configuration-parameters) for the application. If you really wanted to do it exactly like you showed then you would probably make a [PancakeBundle](https://symfony.com/doc/current/bundles/configuration.html). Not recommended unless you wanted to share your pancake functionality with multiple applications. – Cerad Nov 26 '19 at 18:58
  • Im actually trying to build a PancakeBundle, I think would be nice if inside PancakeBundle is a something.yaml to define a custom behavior of the bundle, then it will be installed via composer in a proyect and in that proyect, where the bundle was installed would be another something.yaml to override the custom behavior of PancakeBundle, I'm trying to figure out how to do that since I'm pretty new at Symfony – H3lltronik Nov 26 '19 at 19:18
  • 2
    Maybe study some of the existing bundles. There is no simple way to explain it. Start by [creating a bundle](https://symfony.com/doc/current/bundles.html#creating-a-bundle). Then [create a bundle extension](https://symfony.com/doc/current/bundles/extension.html). Then follow all that up with actually [using the configuration](https://symfony.com/doc/current/bundles/configuration.html). Might be better to just start with some parameters until you get more Symfony experience. – Cerad Nov 26 '19 at 19:26
  • Is there a specific issue with what you have tried that we can help out with? – Will B. Nov 27 '19 at 09:45

1 Answers1

2

you can update the following file :

# config/service.yaml

# This file is the entry point to configure your own services.
# Files in the packages/ subdirectory configure your dependencies.
parameters:
    locale: 'en'
    chat_update_interval: 10000

and use service decoration in your new application to override your parameters.

Pierrick Rambaud
  • 1,726
  • 1
  • 20
  • 47