summaryrefslogtreecommitdiff
path: root/config/credentials.php
blob: 43fa0a4af253f8ea3e210e2f3e0a8973c791747c (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
<?php
/** SERVICE PARAMETRES
 * -----------------------------------------------------------------------------
 * 
 * Connection parametres and credentials for accssing services 
 * needed by the application; Such services may be..
 * 
 * - RDBMS
 *   -- MySQL
 *   -- PotgresSQL
 * 
 * - Caching services
 *   -- Redis
 *   -- MemCached
 * 
 * Edit only the constants needed by the application;
 * Comment those you do not need;
 * 
 * /////////////////////////////////////////////////////////////////////////////
 */

/** DATABASE CONNECTION PARAMETRES
 * -----------------------------------------------------------------------------
 * Production and staging environments may use different databases.
 * 
 * A safe practice is to keep credentials outside plain files like this one
 * in environmental variable or other secret file etc.
 * 
 * Uncomment/enable each group of definitions suits your case to define
 * the credentials needed for accessing the database
 */

/** This is a SAFE method (define credentials as OS environmental variables)
 * -----------------------------------------------------------------------------
 */
# define('DB_NAME', getenv('DB_NAME'));     // database name
# 
# define('DB_USER', getenv('DB_USER'));     // database user-name
# 
# define('DB_PASS', getenv('DB_PASS'));     // user's pass
# 
# define('PDO_HOST', getenv('PDO_HOST'));   // database host (connection string)


/** This is another SAFE method (keep credentials in an .env file)
 * -----------------------------------------------------------------------------
 */

$ini_array = parse_ini_file("../core/auth/.env");

define('DB_NAME', $ini_array['DB_NAME']);

define('DB_USER', $ini_array['DB_USER']);

define('DB_PASS', $ini_array['DB_PASS']);

define('PDO_HOST', $ini_array['PDO_HOST']);


/** This is just good enough
 * -----------------------------------------------------------------------------
 */
#
# if (!PRODUCTION) {    // == Deployed on staging
#
#   // STAGING SETTINGS:
#    
#   define('DB_NAME', 'dev_db_name');
#
#   define('DB_USER', 'devUserName');
#
#   define('DB_PASS', getenv('DBPASSWORD'));
#
#   // PDO_HOST can be a hostname/port combination -or- a unix socket
#   // ...examples:
#   // define('PDO_HOST', 'host=/localhost')    ## hostname case
#   // define('PDO_HOST', 'host=/localhost;port=3456')    ## hostname/port case
#   // define('PDO_HOST', 'unix_socket=/sql/ex123:europe:some-db');   ## unix socket
#   define('PDO_HOST', 'unix_socket=/cloudsql/name-123456:europe-west4:name-db-eu');
#
# } else {        // == Deployed on production
#
#    // PRODUCTION SETTINGS:
#
#    define('DB_NAME', 'your_db_name');
#    define('DB_USER', 'dbusername');
#    define('DB_PASS', getenv('DBPASSWORD'));
#    define('PDO_HOST', 'unix_socket=/cloudsql/name-123456:europe-west4:name-db-eu');
#
#  }

define('DB_TIMEZONE', "SET time_zone = 'Europe/Athens'");

/** NOTE:
 * Both Redis and Memcached configurations are given as a template to work on;
 * In most cases the default values should do the job -- of course you need to
 * read the README file (check the project's root);
 * As these caching services are not fully tested you may need to ochestrate
 * the services in detail or edit the connection strings into the core classes
 * (hosted under the '/core/classes/cacher' folder)
 */


/** REDIS SERVICE
 * -----------------------------------------------------------------------------
 * Most of the times Redis is running on 'localhost' (host = '127.0.0.1')
 * When implemented via anom's docker-composer (redis via bridge) then you need
 * do declare the hostname as 'redis'
 */
#
# if (!defined('REDIS_HOST'))     define('REDIS_HOST', 'redis');
# 
# if (!defined('REDIS_PORT'))     define('REDIS_PORT', 6379);
# 
# if (!defined('REDIS_PASS'))     define('REDIS_PASS', null);


/** MEMCACHED
 * -----------------------------------------------------------------------------
 * Memcached looks very much like Redis (plus, both are serving from RAM)
 * Usualy Memcashed is running localy so host is 'localhost' ('127.0.0.1')
 * If you use the framework's docker-composer implementation then
 * the hostname is 'anomemcached'
 */
#
#if (!defined('MEMCACHE_HOST'))  define('MEMCACHE_HOST', 'anomemcached');