Prepared rewrite of framework bootstrap:
authorRoland Haeder <roland@mxchange.org>
Wed, 29 Jun 2016 21:01:49 +0000 (23:01 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 29 Jun 2016 21:01:49 +0000 (23:01 +0200)
- 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 <roland@mxchange.org>
inc/bootstrap/.htaccess [new file with mode: 0644]
inc/bootstrap/class_BootstrapFramework.php [new file with mode: 0644]
inc/config.php
inc/config/config-local.php-dist
index.php

diff --git a/inc/bootstrap/.htaccess b/inc/bootstrap/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/bootstrap/class_BootstrapFramework.php b/inc/bootstrap/class_BootstrapFramework.php
new file mode 100644 (file)
index 0000000..ee8b6b9
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+/**
+ * A framework-bootstrap class which helps the frameworks to bootstrap ... ;-)
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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]
+?>
index d4b24e7c3bb7deab229ed40fc792b93670d83c6d..859e97aa499830ea49eb32664c5cc355301b4b29 100644 (file)
@@ -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]
 ?>
index 22d8df22678e301cf252a6900cc074b6e96b6882..3ff574b8f86dae6decf6f1a544e448447924b434 100644 (file)
@@ -1,10 +1,12 @@
 <?php
 /**
- * Additional configurations
+ * Additional configuration entries. Do not duplicate it here, instead copy
+ * this to your application's base path (with -dist), add it with "git add" and
+ * ignore config-local.php (add to .gitignore in root path).
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @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
index 0a3ef741158afd0be661a3d36b0c1b63d8e4c89b..b54c766135e0d55fd599451842699bb3280acb6a 100644 (file)
--- 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]