1 | <?php |
||
13 | class Config { |
||
14 | /** |
||
15 | * Basic params |
||
16 | */ |
||
17 | const SITE_TITLE = "Site title"; |
||
18 | |||
19 | /** |
||
20 | * E-mail configuration |
||
21 | */ |
||
22 | const EMAIL_ADMIN = "[email protected]"; |
||
23 | const EMAIL_FROM = "[email protected]"; |
||
24 | const EMAIL_FROM_NAME = "From name"; |
||
25 | const EMAIL_TPL_FOLDER = "templates/email/"; |
||
26 | const EMAIL_SIGNATURE_TPL = "signature.tpl.php"; |
||
27 | |||
28 | /** |
||
29 | * Detects if system runned on the local webserver. |
||
30 | * |
||
31 | * @return boolean |
||
32 | */ |
||
33 | public static function isDevServer() { |
||
36 | |||
37 | /** |
||
38 | * Database configuration. |
||
39 | * You can add additional configurations associated by hostname as an array |
||
40 | * key. |
||
41 | * |
||
42 | * @var array |
||
43 | */ |
||
44 | public static $db = [ |
||
45 | 'default' => [ |
||
46 | 'HOST' => "localhost", |
||
47 | 'DBNAME' => "dbname", |
||
48 | 'USER' => "root", |
||
49 | 'PASSWORD' => "pass", |
||
50 | 'DB_CHARSET' => "utf8" |
||
51 | ] |
||
52 | ]; |
||
53 | |||
54 | /** |
||
55 | * Returns database configuration for current hostname. |
||
56 | * |
||
57 | * @return array |
||
58 | */ |
||
59 | public static function getDBConfig() { |
||
65 | |||
66 | /** |
||
67 | * Returns database configuration parameter. |
||
68 | * |
||
69 | * @param string $paramName Parameter name. |
||
70 | * @return string |
||
71 | */ |
||
72 | public static function getDBConfigParam($paramName) { |
||
79 | |||
80 | /** |
||
81 | * FS |
||
82 | */ |
||
83 | const DIR_UPLOADS = "uploads/"; |
||
84 | const DIR_AVATARS = "uploads/avatars/"; |
||
85 | |||
86 | /** |
||
87 | * UI |
||
88 | */ |
||
89 | const ITEMS_PER_PAGE = 15; |
||
90 | |||
91 | /** |
||
92 | * You can add you custom parameters here. |
||
93 | */ |
||
94 | |||
95 | } |
||
96 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: