Posted By

ryantxr on 07/30/12


Tagged

php bootstrap autoloader


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

tux-world
ringo380


PHP bootstrap


 / Published in: PHP
 

Application bootstrap to get some startup code out of the way. This one has an autoloader.

  1. // put this in bootstrap.php and place in the main app dir
  2. date_default_timezone_set('America/New_York');
  3. define('DS', DIRECTORY_SEPARATOR);
  4. define('PS', PATH_SEPARATOR);
  5. define('APPDIR', dirname(__FILE__));
  6. define('INCDIR', APPDIR . DS . 'include');
  7.  
  8. function x_autoload($cls){
  9. @include_once($cls . '.php');
  10.  
  11. // does the class requested actually exist now?
  12. if (class_exists($cls, false)) {
  13. // yes, we're done
  14. return;
  15. }
  16. }
  17. spl_autoload_register('x_autoload');

Report this snippet  

You need to login to post a comment.