diff options
Diffstat (limited to 'core/config')
| -rw-r--r-- | core/config/anom_settings.php | 229 |
1 files changed, 131 insertions, 98 deletions
diff --git a/core/config/anom_settings.php b/core/config/anom_settings.php index 50056bf..060f948 100644 --- a/core/config/anom_settings.php +++ b/core/config/anom_settings.php @@ -1,160 +1,193 @@ <?php - -/** CONFIGURATION PATAMETRES +/** CONFIGURATION PARAMETRES * ----------------------------------------------------------------------------- - * This is the first file you need to setup - * in order to start a new application + * + * 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 manualy setting any values manualy - * Here we propose that you use an .env file (with is a very safe option) - * the env file is saved into `/core/auth` folder + * 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"); } -// DEFINE WHETTHER THE APP RUNS ON PRODUCTION -// Don't forget to change this setting -// when deploying to a different stage -// ----------------------------------------------------------------------------- - -# // define by OS parameter -# if (getenv('ENVIRONMENT')) { -# if (getenv('ENVIRONMENT') == 'PRODUCTION') { -# define('PRODUCTION', true); -# } else { -# define('PRODUCTION', false); -# } -# } - -# define by .env file + + + +/** 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') ); -// Custom Names //////////////////////////////////////////////////////////////// -// ----------------------------------------------------------------------------- -define('APP_NAME', 'e-Classroom'); // Application Name +/** 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', 'v0.2'); // Application version +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('SESSION_NAME', 'clroom'); // Session Name +define('SITE_URL', $ini['ANOM_HOSTNAME']); -/** APPLICATION PATHS /////////////////////////////////////////////////////////// + +/** APPLICATION PATHS * ----------------------------------------------------------------------------- * - * Obligarory + * Obligarory: * These are needed in order to run the bare minimum MVC system * They also make code easier to read * * NOTE: - * probably you don't need to chage these defines + * 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', dirname(get_included_files()[0]) ); +define('APP_ROOT', $ini['APP_ROOT'] ?? dirname(get_included_files()[0]) ); define('URL_ROOT', '/'); - -define('CREDENTIALS', '../core/config/credentials.php'); - + 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/")); -define('RENDERING_SYSTEM', '../core/helpers/render.php'); - -define('VIEWS_DIRECTORY', APP_ROOT.'/app/views/'); -define('TESTS_DIRECTORY', APP_ROOT."/../tests/"); /** AUTOLOADER ///////////////////////////////////////////////////////////////// * ----------------------------------------------------------------------------- + * * An autoloader for classes is required; * * - * OPTION 1: COMPOSER + ** 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 - */ -# define('AUTOLOADER' , '../core/helpers/autoload.php'); - -/** CLASSPATHS : array of paths where classes are saved - * Needed only when the custom autoloader is used - * (like autoload.classmap section of Composer) - */ -# define('CLASSPATHS', array( -# '/../core/classes/', -# '/app/controllers/', -# '/app/models/', -# '/../vendor/' -# ) -# ); - + define('AUTOLOADER' , '../vendor/autoload.php'); - /** SESSION HANDLING ////////////////////////////////////////////////////////// - * ---------------------------------------------------------------------------- + /** OPTION 2: Custom Autoloader + * ----------------------------------------------------------------------------- + * If Composer is not supported, another autoloading proccess required + * Comment/Disable the 1st option and uncomment/Enable the next line + * ----------------------------------------------------------------------------- * - * 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 - * ---------------------------------------------------------------------------- + * NOTE: if the custom autoloadet is used + * then you need to defing CLASSPATHS constant-array too; */ + + # define('AUTOLOADER' , '../core/helpers/autoload.php'); -define('SESSION_DRIVER', 'DefaultSession'); -// if FileSession is selected, a path for session-files is needed -# define('FILESESSION_PATH', '../storage/session'); -/* 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; - * ----------------------------------------------------------------------------- + +/** 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('CACHE_DRIVER', 'FileCache'); + define('SESSION_DRIVER', $ini['SESSION_DRIVER']); -/** Caching expiration times fpr various expensive objects - * ----------------------------------------------------------------------------- - */ -// Root objects like product-categories tree -define('CACHE_ROOT_TTL', 28800); // 8 hours + + /** 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']); -// Product Category -define('CACHE_CATEGORY_TTL', 18000); // 5 hours -// Product -define('CACHE_PRODUCT_TTL', 3600); // 1 hour +/** HOTFIX: (needs refactoring) */ // CONNECTIONS ... |
