summaryrefslogtreecommitdiff
path: root/config/credentials.php
diff options
context:
space:
mode:
Diffstat (limited to 'config/credentials.php')
-rw-r--r--config/credentials.php126
1 files changed, 126 insertions, 0 deletions
diff --git a/config/credentials.php b/config/credentials.php
new file mode 100644
index 0000000..43fa0a4
--- /dev/null
+++ b/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');