So right now I’m developing an app in Symfony4 where the users can create files with one parameter that can be chosen between a variety of options (these options being already defined), for example:
Year = [2020,2019,2018,2017]; Type = ['A','B','C']; User = [ 'User' => 'ROLE_USER', 'Admin' => 'ROLE_ADMIN', 'Guest' => 'ROLE_GUEST', ];
And I would like that the admin could change this variables by adding a new year or adding a new type of file.
So I thought that this could be achievable by creating a global variable for the whole app (a variable that can be accessed from everywhere) in order to use it in the forms, views, etc. But I dont know how to do it.
I think I could do it in two ways:
- Creating a specific table in the db for these parameters, this way using doctrine to fetch the data and being able to updating it easily. (One more call to the database every time I want to use it)
- Or creating a global variable as I said before that I can access everytime I want
What should I do?
Is there any other easier way to achieve this?
Thank you very much in advance
Source: Symfony Questions