alankis

Untitled

Mar 5th, 2014
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.09 KB | None | 0 0
  1. <?php
  2. /*
  3.  * Basic application enviroment
  4.  * BASEPATH constant uses as script access control, so One doesn't have to
  5.  * put .htaccess file in every class folder
  6.  */
  7.  
  8. define('BASEPATH', '/');
  9. /**
  10.  * Use it as main application wrapper, where configures, initializes and
  11.  * run your app
  12.  */
  13. final class App
  14. {
  15.     private $conf;
  16.     /**
  17.      * Initialize and configures applications
  18.      */
  19.     public function initApp()
  20.     {
  21.        
  22.         spl_autoload_register(array($this,'loadClass'));
  23.         $this->conf = Config::getConfigData( 'db' );
  24.     }
  25.    
  26.     /**
  27.      * Load all needed classes - called by spl_autoload register
  28.      */
  29.     private function loadClass( $name )
  30.     {
  31.        $classes = array(
  32.            'Utils'  => 'utils/Utils.php',
  33.            'Config' => 'config/Config.php'
  34.        );
  35.       if ( !key_exists($name, $classes ) )
  36.       {
  37.           die("Can't find " . $name . " class!");
  38.       }
  39.       require_once($classes[$name]);
  40.     }
  41. }
  42.  
  43. $app = new App();
  44. $app->initApp();
  45.  
  46. Utils::dumpVar(App::$conf);
  47.  
  48. $db = new PDO($dsn, $username, $passwd, $options);
Advertisement
Add Comment
Please, Sign In to add comment