After a few years in PHP development, I saw and heard various ways of storing "global area data" (global, constant, ini / XML / YML files, databases, singleton properties ...).
By "global area data" I mean:
- Global application / project settings, such as
- Database configuration
- SMTP, FTP options
- Database identifiers (for example, primary key values ββfor specific languages ββor countries defined in the database)
- Global runtime parameters such as
- Enable Logging / Debugging
- Environment - dev / test / prod
- and etc.
... which should not change after extraction and should be easily accessible in any part of the project code.
Some global data can be stored as an associative array (therefore, it cannot be declared permanent).
For example: date formats for each language. By the way, I saw this other SO question about array constants, but isn't there something more readable than using unserialize wherever a constant array value is required?
My main question is: how would you recommend correctly storing (I mean clean, readable, reliable) data from the global area and why (pros / cons)?
Thanks.
source share