summaryrefslogtreecommitdiff
path: root/core/config/anom_settings.php
blob: 03e4cc5105ec61f3acfc90589284eb26aa5d741c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<?php
/** CONFIGURATION PARAMETRES
 * -----------------------------------------------------------------------------
 * 
 * Here you can find all the setup paramaters that define
 * key-decisions of your application;
 * 
 * ex. Session driver, Cache driver, Cookies Policy etc;
 * 
 * Other supplamentary constants (ex. Session options according to the driver,
 * Cookie properties according to the application's specs) shall be defined
 * into the ~/public/app/config/app_constants.php
 * 
 * 
 * NOTE:
 * You may rewrite the defines setting any values manualy
 * SETTING anom CONSTANTS VIA an `.env` FILE IS HIGHLY RECOMMENDED (for safety)
 * The default env file is saved into `~/core/auth` folder
 *  
 * -----------------------------------------------------------------------------
 */

if (file_exists("../core/auth/.env")) {
    $ini = parse_ini_file("../core/auth/.env");
}




/** ENVIRONMENT constant
 * -----------------------------------------------------------------------------
 * 
 * define application's environment stage; [PRODUCTION|develpment|testing|*]
 * seting this constant to 'PRODUCTION' eliminates debuggin comments;
 * 
 * DO NOT FORGET to change this setting when deploying to a different stage
 * 
 * -----------------------------------------------------------------------------
 */

define('PRODUCTION', ($ini['ENVIRONMENT'] == 'production') );




/** APPLICATION NAMES AND URL DEFAULTS
 * -----------------------------------------------------------------------------
 * 
 * NOTE:
 * if .env file exists ... do not touch anything
 * else ... replace $env[*] values with your setup
 * 
 * -----------------------------------------------------------------------------
 */

define('APP_NAME', $ini['APP_NAME']);         // Application Name (how developer refers to it)

define('APP_VERSION', $ini['APP_VERSION']);   // Application version (major_version + subversion_class)
                                              // keep it simple, ex: '1.alfa'  -or-  '1.beta'  -or-  '2.rc'

define('SITE_URL', $ini['ANOM_HOSTNAME']);




/** APPLICATION PATHS
 * -----------------------------------------------------------------------------
 * 
 * Obligarory:
 * These are needed in order to run the bare minimum MVC system
 * They also make code easier to read
 * 
 * NOTE:
 * most likely won't need to change any of these subsection defines;
 * still the framework makes easy for the developer
 * to change the Views and/or the Tests diectrory;
 * 
 * -----------------------------------------------------------------------------
 */

define('APP_ROOT', $ini['APP_ROOT'] ?? dirname(get_included_files()[0]) );

define('URL_ROOT', '/');

define('INIT_APPLICATION', '../core/config/init.php');

define('VIEWS_DIRECTORY', $ini['VIEWS_DIRECTORY'] ?? (APP_ROOT.'/app/views/'));

define('TESTS_DIRECTORY', $ini['TESTS_DIRECTORY'] ?? (APP_ROOT."/../tests/"));




/** AUTOLOADER /////////////////////////////////////////////////////////////////
 * -----------------------------------------------------------------------------
 * 
 * An autoloader for classes is required;
 * 
 * 
 ** OPTION 1: COMPOSER
 * -----------------------------------------------------------------------------
 * Composer is recommended and makes much more than simple autoloding
 * -----------------------------------------------------------------------------
 */

define('AUTOLOADER' , '../vendor/autoload.php');

/** OPTION 2: Custom Autoloader
 * -----------------------------------------------------------------------------
 * If Composer is not supported, another autoloading proccess required
 * Comment/Disable the 1st option and uncomment/Enable the next line
 * -----------------------------------------------------------------------------
 * 
 * NOTE: if the custom autoloadet is used
 * then you need to defing CLASSPATHS constant-array too;
 */

# define('AUTOLOADER' , '../core/helpers/autoload.php');




/** SESSION HANDLING
 * ----------------------------------------------------------------------------
 * 
 * there are several session drivers for session handling:
 *    
 * 'DefaultSession'  : uses the default (file-based) php session management
 * 'FileSession'     : defines a custom file-based session mechanism
 * 'DatabaseSession' : mechanism that stores Session data into a DataBase
 * ----------------------------------------------------------------------------
 */

define('SESSION_DRIVER', $ini['SESSION_DRIVER']);



  
/** COOKIE SETTINGS
 * -----------------------------------------------------------------------------
 * 
 * Define cookie policy (cookie sharing and securing)
 * 
 * recomended values for production environment:
 * COOKIE_SECURE=true
 * COOKIE_SAMESITE='Strict'
 * 
 * NOTE:
 * on development environment COOKIE_SECURE has to be false
 * in order for the test server to use them from http://locahost
 * 
 * for more info about cookie policy read:
 * https://www.php.net/manual/en/function.session-set-cookie-params.php
 * 
 * -----------------------------------------------------------------------------
 */

define('COOKIE_SECURE', PRODUCTION);    // Secure cookie policy [true|false]

define('COOKIE_SAMESITE', $ini['COOKIE_SAMESITE'] ?? 'Strict');    // SameSite cookie policy [Strict|Lax|None]
    
# define('COOKIE_DOMAIN', $env['ANOM_HOSTNAME']);   // domain to be visible on




/* ADVANCED OPTIMIZATION ///////////////////////////////////////////////////////
 * -----------------------------------------------------------------------------
 *
 * APP_CACHE defines the cache-driver;
 * accepted values are the name of the Cache-interface impementations (the exact
 * names of the classes)
 *
 * 'FileCache'  : caching in filesystem; fair if caching on HDD; great on SSD
 * 'RedisCache' : caching in Redis server; generally recommended if available
 * 'MemCachedCache' : caching in Memcached server; recommended if available
 *
 * NOTE: FileCache on a NVMe SDD is the fastest option;
 * Redis and Memcached are really-fast caching options and are available for
 * scaling horizontaly your application (eache one has it's own strngths;
 * study, then choose the one that fulfills your needs;
 * -----------------------------------------------------------------------------
 */
  
define('CACHE_DRIVER', $ini['CACHE_DRIVER']);




/** HOTFIX: (needs refactoring) */

// CONNECTIONS ...

define('FILECACHE_PATH', APP_ROOT.'/../storage/cache/');     // if CACHE_DRIVER is set to 'FileCache'

define('MEDIA_STORAGE_ROOT', APP_ROOT.'/../storage/uploads/');    // Media files root directory

# define('REDIS_HOST', '127.0.0.1');              // if CACHE_DRIVER is set to 'RedisCache'

# define('MEMCAHCED_SERVER', '127.0.0.1');        // if CACHE_DRIVER is set to 'MemCached'




/** CREDENTIALS
 * -----------------------------------------------------------------------------
 */