diff --git a/.gitignore b/.gitignore index edb419a..a5713bf 100644 --- a/.gitignore +++ b/.gitignore @@ -2,10 +2,6 @@ /.idea/* /.vscode/* -# Config -/system/config/config.php -/system/config/ini.php - # Libraries /system/composer/vendor/* /src/view/www/node_modules/* diff --git a/index.php b/index.php index e15bf3a..55be5fc 100644 --- a/index.php +++ b/index.php @@ -14,7 +14,7 @@ require SYSTEM . "engine/Router.php"; require SYSTEM . "engine/Controller.php"; require SYSTEM . "engine/SessionSecureHandler.php"; -require SYSTEM . "engine/Errors.php"; +require SYSTEM . "engine/Log.php"; require SYSTEM . "engine/AutoLoader.php"; // AutoLoader @@ -25,6 +25,9 @@ $loader->addNamespace('Services', DIR_ROOT.'/system/services'); $loader->addNamespace('Engine', DIR_ROOT.'/system/engine'); +// Define environment +putenv("ENVIRONMENT=DEVELOPMENT"); + // Bootstrap require SYSTEM . "config/ini.php"; require SYSTEM . "startup.php"; diff --git a/src/view/www/package.json b/src/view/www/package.json index e341b59..82d39fd 100644 --- a/src/view/www/package.json +++ b/src/view/www/package.json @@ -2,7 +2,6 @@ "name": "light-php", "version": "1.0.0", "description": "", - "main": ".eslintrc.js", "scripts": { "lint": "eslint \"src/**/*.js\" " }, diff --git a/system/config/_config.php b/system/config/_config.php deleted file mode 100644 index f52062a..0000000 --- a/system/config/_config.php +++ /dev/null @@ -1,33 +0,0 @@ - "", - "database_user" => "", - "database_pass" => "", - "dabatase_name" => "", - "session_name" => "session", - "session_encrypt_method" => "aes-256-cbc", - "session_iv" => "ThisIsMySecretIv", // Generated automatically in the install process - "session_key" => "ThisIsMySecretPass", // Generated automatically in the install process - "email_host" => "", - "email_name" => "", - "email_pass" => "", - "email_port" => "", - "email_from" => "", - "system_default_time_zone" => "Europe/Madrid", - "system_debug_console" => true, - "system_execution_time" => microtime(true), - "system_cache_version" => 0001, // Refresh frontend cache - "system_allow_forms_without_csrf" => false -]; diff --git a/system/config/config.php b/system/config/config.php new file mode 100644 index 0000000..f0f2911 --- /dev/null +++ b/system/config/config.php @@ -0,0 +1,55 @@ + [ + "database_host" => "", + "database_user" => "", + "database_pass" => "", + "dabatase_name" => "", + "session_name" => "session", + "session_encrypt_method" => "aes-256-cbc", + "session_iv" => "ThisIsMySecretIv", // Generated automatically in the install process + "session_key" => "ThisIsMySecretPass", // Generated automatically in the install process + "email_host" => "", + "email_name" => "", + "email_pass" => "", + "email_port" => "", + "email_from" => "", + "system_default_time_zone" => "Europe/Madrid", + "system_debug_console" => true, + "system_execution_time" => microtime(true), + "system_cache_version" => 0001, // Refresh frontend cache + "system_allow_forms_without_csrf" => false + ], + "production" => [ + "database_host" => "", + "database_user" => "", + "database_pass" => "", + "dabatase_name" => "", + "session_name" => "session", + "session_encrypt_method" => "aes-256-cbc", + "session_iv" => "ThisIsMySecretIv", // Generated automatically in the install process + "session_key" => "ThisIsMySecretPass", // Generated automatically in the install process + "email_host" => "", + "email_name" => "", + "email_pass" => "", + "email_port" => "", + "email_from" => "", + "system_default_time_zone" => "Europe/Madrid", + "system_debug_console" => true, + "system_execution_time" => microtime(true), + "system_cache_version" => 0001, // Refresh frontend cache + "system_allow_forms_without_csrf" => false + ] +]; diff --git a/system/config/_ini.php b/system/config/ini.php similarity index 100% rename from system/config/_ini.php rename to system/config/ini.php diff --git a/system/config/routes.php b/system/config/routes.php index e4a4515..26f1265 100644 --- a/system/config/routes.php +++ b/system/config/routes.php @@ -4,8 +4,8 @@ * Array key => url * Array value => folder/class/method (index method if none specified) */ - -$routes = array(); -$routes["/"] = "index/index/index"; -$routes["/welcome"] = "index/index/index"; -$routes["/sample"] = "index/index/samplePage"; +return [ + "/" => "index/index/index", + "/welcome" => "index/index/index", + "/sample" => "index/index/samplePage" +]; diff --git a/system/services/Log.php b/system/services/Log.php index 60c523f..bf543f8 100644 --- a/system/services/Log.php +++ b/system/services/Log.php @@ -7,7 +7,7 @@ /** * Error handling class, define callbacks to execute when warnings, errors, exceptions and unknown errors happen */ -class Errors extends Singleton +class Log extends Singleton { public $error_handle; @@ -17,7 +17,7 @@ class Errors extends Singleton private $unknown_errors_log_path; /** - * + * */ public function __construct($error_log_path, $notice_log_path, $warning_log_path, $unknown_errors_log_path) { $this->error_log_path = $error_log_path; @@ -25,7 +25,7 @@ public function __construct($error_log_path, $notice_log_path, $warning_log_path $this->warning_log_path = $warning_log_path; $this->unknown_errors_log_path = $unknown_errors_log_path; } - + /** * Error handler, parses the error, and wether it's a warning, exception, notice or something else, executes the * correct callback diff --git a/system/startup.php b/system/startup.php index 4508404..b910057 100644 --- a/system/startup.php +++ b/system/startup.php @@ -18,7 +18,7 @@ date_default_timezone_set(Config::get("default_time_zone")); // Error/Warning/Notice handler -$error_class = new Errors(); +$error_class = new Log(); set_error_handler(array($error_class,"myErrorHandler"), E_ALL); error_reporting(E_ALL);