Search code examples
symfony1yamllookup

What is the best way to access lookup values in symfony? On the database or constants?


I am creating a web project and want it to be optimized. Instead of accessing lookup values in the database (to minimize access), I think it should be stored somewhere in symfony. What is the best way to this? In YML with PHP Array?


Solution

  • Another option I use for values that should never change and that are not environment-specific is to define constants in a relevant model or helper class.

    The advantages are:

    1) if you name those constants well using them helps make the code more self-documenting

    2) if you use an IDE with autocompletion features it will look up and verify their names as you're coding.

    3) they are the fastest possible method of lookup.