PHP - Application config file stored as - ini,php,sql,cached,php class,JSON,php array?

后端 未结 10 827
死守一世寂寞
死守一世寂寞 2020-12-13 14:15

I am trying to decide on the best way to store my applications configuration settings. There are so many options.

The majority of applications I have seen have used

10条回答
  •  我在风中等你
    2020-12-13 14:53

    We use a file called Local.php which is excluded from the SCM system. It contains several constants or global variables. For example:

    // Local.php
    class Setting
    {
       const URL = 'http://www.foo.com';
       const DB_User = 'websmith';
    }
    

    And it can be referred to anywhere simply by:

    Setting::URL
    

    If you need the settings to be writable at runtime, I suggest you use public static variables instead.

提交回复
热议问题