Menu Close
    Hire us Request quote Reading list Switch to dark mode

    Symfony – How to get parameters value in Controller and Twig

    In Symfony, we defined various parameters in Parameters.yml so that our application can use these in various places. Example –

    But how can we access these values in our Controller or Twig ? Simple 🙂 using getParameter function you can easily access these.

    To access these parameters you have to define these in Config.yml file, under twig key with globals keyword like database_name

    using %% you can access defined values like we use $ in php for variables.

    . . .
    Subscribe Articles

    Just enter your email below to subscribe and receive weekly updates about the most interesting similar articles.

    You need to accept conditions to receive letters.
    You've Subscribed!

    Share article via

    . . .

    Twig template code

    Symfony version used – 2.7

    . . .

    Comments (2)

    Add Your Comment

  • Potworny
    Thank you 🙂
    • Webkul Support
      You are most welcome.
  • Back to Top
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again