diff options
| author | Geo Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-05-15 18:15:37 +0300 |
|---|---|---|
| committer | Geo Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-05-15 18:15:37 +0300 |
| commit | 59cd40235bf4746a119421609b25d7e9b7f65f83 (patch) | |
| tree | 35a4929d59ed87b97219ea992e4cbcdc994a78d5 /core | |
| parent | 0d983359abb511f75aa5f0b2b498b97728eb25a3 (diff) | |
| download | gyraf1gov-59cd40235bf4746a119421609b25d7e9b7f65f83.tar.gz gyraf1gov-59cd40235bf4746a119421609b25d7e9b7f65f83.tar.bz2 gyraf1gov-59cd40235bf4746a119421609b25d7e9b7f65f83.zip | |
refactoring framework defaults
Diffstat (limited to 'core')
| -rw-r--r-- | core/auth/env.example | 36 | ||||
| -rw-r--r-- | core/classes/Database.php | 2 | ||||
| -rw-r--r-- | core/config/anom_settings.php | 209 | ||||
| -rw-r--r-- | core/config/init.php | 11 | ||||
| -rw-r--r-- | core/config/xx--anom_settings.php | 66 | ||||
| -rw-r--r-- | core/config/xx--constants.php (renamed from core/config/constants.php) | 0 | ||||
| -rw-r--r-- | core/helpers/autoload.php | 2 |
7 files changed, 71 insertions, 255 deletions
diff --git a/core/auth/env.example b/core/auth/env.example deleted file mode 100644 index fd47dd8..0000000 --- a/core/auth/env.example +++ /dev/null @@ -1,36 +0,0 @@ -ENVIRONMENT='development' - -# MySQL connection -# --- -- -- - - - -DB_NAME= -DB_USER= -DB_PASS= -PDO_HOST= - -# mailhog -# == testting/fake email service -# --- -- -- - - - -# MAIL_HOST=mailhog_server -# MAIL_PORT=1025 -# MAIL_USERNAME= -# MAIL_PASSWORD= -# MAIL_ENCRYPTION= - -# SMTP setup -# == read mail server -# --- -- -- - - - -MAIL_MAILER=smtp -MAIL_HOST= -MAIL_PORT=465 -MAIL_USERNAME= -MAIL_PASSWORD= -MAIL_ENCRYPTION=ssl -NO_REPLY_EMAIL=noreply@... -REPLY_TO_EMAIL=webmaster@r... -MAIL_FROM_NAME=Classroom - -# redis cache server -# --- -- -- - - - -# REDIS_HOST=redis -# REDIS_PASSWORD= -# REDIS_PORT=6379
\ No newline at end of file diff --git a/core/classes/Database.php b/core/classes/Database.php index 0a8a10a..9de9872 100644 --- a/core/classes/Database.php +++ b/core/classes/Database.php @@ -125,7 +125,7 @@ class Database { } // keep rowCount (valid for INSERT, UPDATE, DELETE) - $this->rowCount = $stmt->rowCount(); + $this->rowCount = $stmt->rowCount(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); diff --git a/core/config/anom_settings.php b/core/config/anom_settings.php deleted file mode 100644 index 03e4cc5..0000000 --- a/core/config/anom_settings.php +++ /dev/null @@ -1,209 +0,0 @@ -<?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 - * ----------------------------------------------------------------------------- - */ - -
\ No newline at end of file diff --git a/core/config/init.php b/core/config/init.php index 589a486..40624d3 100644 --- a/core/config/init.php +++ b/core/config/init.php @@ -18,14 +18,9 @@ // setup error-handliing // ----------------------------------------------------------------------------- -require_once '../core/helpers/error_handling.php'; +require_once APP_ROOT.'/core/helpers/error_handling.php'; -// depricated: -/// // Load rendering sub-system -/// // ----------------------------------------------------------------------------- -/// require_once RENDERING_SYSTEM; - // Setup Application Engiine // ----------------------------------------------------------------------------- @@ -55,10 +50,10 @@ Registry::set('REQUEST', new Request()); // (these patterns use some of the project's central objects (Registry, // Cache, Database), so laod them after. // ----------------------------------------------------------------------------- -require_once '../core/helpers/design_patterns.php'; +require_once APP_ROOT.'/core/helpers/design_patterns.php'; // Add Routes // ----------------------------------------------------------------------------- -require_once 'app/config/init_routes.php'; // initialize routes +require_once WEB_ROOT.'/app/config/init_routes.php'; // initialize routes diff --git a/core/config/xx--anom_settings.php b/core/config/xx--anom_settings.php new file mode 100644 index 0000000..06fe5af --- /dev/null +++ b/core/config/xx--anom_settings.php @@ -0,0 +1,66 @@ +<?php + + + + + + + + + + + + + + + + + + + + + + +/* 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', $env['CACHE_DRIVER'] ?? 'FileCache'); + + + + +/** 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 + * ----------------------------------------------------------------------------- + */ + +
\ No newline at end of file diff --git a/core/config/constants.php b/core/config/xx--constants.php index d2ecc41..d2ecc41 100644 --- a/core/config/constants.php +++ b/core/config/xx--constants.php diff --git a/core/helpers/autoload.php b/core/helpers/autoload.php index c4359c6..c72c335 100644 --- a/core/helpers/autoload.php +++ b/core/helpers/autoload.php @@ -18,7 +18,7 @@ spl_autoload_register( // check all possible classPaths for class foreach(CLASSPATHS as $key => $basePath) { - $file = APP_ROOT . $basePath . $classPath .'.php'; + $file = WEB_ROOT . $basePath . $classPath .'.php'; // if class-file exist, include it if (file_exists($file)) { |
