diff options
| author | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-03-12 07:16:23 +0200 |
|---|---|---|
| committer | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-03-12 07:16:23 +0200 |
| commit | 7076343338ae3439f3c86f01144818abe8c31978 (patch) | |
| tree | 794abb1e6b8f821091fd095341885496b6dad51d /core/config/credentials.php | |
| parent | 47cbb529f5723b246125ae083a193e11481b89ef (diff) | |
| download | classroom-7076343338ae3439f3c86f01144818abe8c31978.tar.gz classroom-7076343338ae3439f3c86f01144818abe8c31978.tar.bz2 classroom-7076343338ae3439f3c86f01144818abe8c31978.zip | |
add container helpers; constuct public directory-tree
Diffstat (limited to 'core/config/credentials.php')
| -rw-r--r-- | core/config/credentials.php | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/core/config/credentials.php b/core/config/credentials.php new file mode 100644 index 0000000..43fa0a4 --- /dev/null +++ b/core/config/credentials.php @@ -0,0 +1,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'); |
