From: Roland Haeder Date: Wed, 29 Jun 2016 21:01:49 +0000 (+0200) Subject: Prepared rewrite of framework bootstrap: X-Git-Url: https://git.mxchange.org/?p=core.git;a=commitdiff_plain;h=9d1de68caa0fb93f1862f1f8d3939aa15405cee7 Prepared rewrite of framework bootstrap: - added initial class 'BootstrapFramework' which doesn't need to be instanciated as only static methods will come - $cfg in inc/config.php is now being unset, it is not good coding practice to then use it outside the scope of the included file - you then need to get $cfg again from FrameworkConfiguration::getSelfInstance() to be able to set/get configuration entries. - added note how to deal with inc/config/config-local.php-dist which is an example how to use it in your own applications. - minor improvements (comments) Signed-off-by: Roland Häder --- diff --git a/inc/bootstrap/.htaccess b/inc/bootstrap/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/bootstrap/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/bootstrap/class_BootstrapFramework.php b/inc/bootstrap/class_BootstrapFramework.php new file mode 100644 index 00000000..ee8b6b95 --- /dev/null +++ b/inc/bootstrap/class_BootstrapFramework.php @@ -0,0 +1,35 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BootstrapFramework { + /** + * Private constructor, no instance is needed from this class as only + * static methods exist. + */ + private function __construct () { + // Prevent making instances from this "utilities" class + } +} + +// [EOF] +?> diff --git a/inc/config.php b/inc/config.php index d4b24e7c..859e97aa 100644 --- a/inc/config.php +++ b/inc/config.php @@ -48,6 +48,7 @@ $cfg->setConfigEntry('local_db_path', $cfg->getConfigEntry('base_path') . 'db/') $cfg->setDefaultTimezone('Europe/Berlin'); // CFG: MAGIC-QUOTES-RUNTIME +// @DEPRECATED As PHP is deprecating this $cfg->setMagicQuotesRuntime(FALSE); // CFG: CLASS-PREFIX @@ -282,10 +283,10 @@ $cfg->setConfigEntry('salt_length', 10); $cfg->setConfigEntry('rnd_str_length', 128); // CFG: HASH-EXTRA-MASK -$cfg->setConfigEntry('hash_extra_mask', "%1s:%2s:%3s"); // 1=salt, 2=extra salt, 3=plain password/string +$cfg->setConfigEntry('hash_extra_mask', '%1s:%2s:%3s'); // 1=salt, 2=extra salt, 3=plain password/string // CFG: HASH-NORMAL-MASK -$cfg->setConfigEntry('hash_normal_mask', "%1s:%2s"); // 1=salt, 2=plain password/string +$cfg->setConfigEntry('hash_normal_mask', '%1s:%2s'); // 1=salt, 2=plain password/string // CFG: IS-SINGLE-SERVER $cfg->setConfigEntry('is_single_server', 'Y'); @@ -470,5 +471,8 @@ $cfg->setConfigEntry('extension_scrypt_loaded', FALSE); // CFG: EXTENSION-UUID-LOADED (By default uuid is assumed absent and later tested being there) $cfg->setConfigEntry('extension_uuid_loaded', FALSE); +// Remove config from this name-space. Don't worry, no configuration is cleared. +unset($cfg); + // [EOF] ?> diff --git a/inc/config/config-local.php-dist b/inc/config/config-local.php-dist index 22d8df22..3ff574b8 100644 --- a/inc/config/config-local.php-dist +++ b/inc/config/config-local.php-dist @@ -1,10 +1,12 @@ * @version 0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team * @license GNU GPL 3.0 or any newer version * * This program is free software: you can redistribute it and/or modify diff --git a/index.php b/index.php index 0a3ef741..b54c7661 100644 --- a/index.php +++ b/index.php @@ -183,24 +183,32 @@ final class ApplicationEntryPoint { } /** - * The application's main entry point. This class isolates some local + * The framework's main entry point. This class isolates some local * variables which shall not become visible to outside because of security - * concerns. We are doing this here to "emulate" the well-known entry - * point in Java. + * concerns. This is done here to "emulate" the well-known entry point in + * Java. * * @return void */ public static final function main () { - // Load config file + // Load config file, this provides $cfg require(self::detectCorePath() . '/inc/config.php'); + // Get a new configuration instance + $cfg = FrameworkConfiguration::getSelfInstance(); + + // Load bootstrap class + require($cfg->getConfigEntry('base_path') . 'inc/bootstrap/class_BootstrapFramework.php'); + + // ----- Below is deprecated ----- + // Load all include files require($cfg->getConfigEntry('base_path') . 'inc/includes.php'); // Include the application selector require($cfg->getConfigEntry('base_path') . 'inc/selector.php'); - } // END - main() -} // END - class + } +} // Developer mode active? Comment out if no dev! define('DEVELOPER', TRUE); @@ -210,7 +218,7 @@ define('DEVELOPER', TRUE); //xdebug_start_trace(); -// Do not remove the following line: +// Call above main() method ApplicationEntryPoint::main(); // [EOF]