Skip to content
Advertisement

How Can I define global CONST variables in Symfony framework?

How Can I define global CONST variables in my app symfony ? What are the good practices define global variables in symfony? Mayby Should I create interface and use DI ?

Advertisement

Answer

You should add your variables into app/config/config.yml;

# app/config/config.yml
parameters:
    myVariable: 10

And you can use it;

$this->getParameter('myVariable');
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement