PHPonTrax
[ class tree: PHPonTrax ] [ index: PHPonTrax ] [ all elements ]

Source for file environment.php

Documentation is available at environment.php

  1. <?php
  2. /**
  3. * @package PHPonTrax
  4. */
  5. # include path for your php libs (PEAR etc)
  6. define("PHP_LIB_ROOT", "/usr/local/lib/php");
  7. define("TRAX_ROOT", dirname(dirname(__FILE__)) . "/");
  8. define("TRAX_PUBLIC", dirname(dirname(dirname(__FILE__)))."/public");
  9. define("TRAX_URL_PREFIX", null); # no leading or trailing slashes
  10. define("TRAX_VIEWS_EXTENTION", "phtml");
  11.  
  12. # Set in the Apache Vhost (SetEnv TRAX_MODE development)
  13. if(isset($_SERVER) && array_key_exists('TRAX_MODE',$_SERVER)) {
  14. # Set from Env production / development / test
  15. define("TRAX_MODE", $_SERVER['TRAX_MODE']);
  16. } else {
  17. # Manually set production / development / test
  18. define("TRAX_MODE", "development");
  19. }
  20.  
  21. $GLOBALS['TRAX_INCLUDES'] =
  22. array( "models" => "app/models",
  23. "views" => "app/views",
  24. "controllers" => "app/controllers",
  25. "helpers" => "app/helpers",
  26. "layouts" => "app/views/layouts",
  27. "config" => "config",
  28. "environments" => "config/environments",
  29. "lib" => "lib",
  30. "app" => "app",
  31. "log" => "log",
  32. "vendor" => "vendor" );
  33.  
  34. if (substr(PHP_OS, 0, 3) == 'WIN') {
  35. # Windows
  36. define("TRAX_PATH_SEPERATOR", ";");
  37. } else {
  38. # Unix
  39. define("TRAX_PATH_SEPERATOR", ":");
  40. }
  41.  
  42. # Set which file to log php errors to for this application
  43. # As well in your application you can do error_log("whatever") and it will go to this log file.
  44. ini_set("log_errors", "On");
  45. ini_set("error_log", TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['log']."/".TRAX_MODE.".log");
  46.  
  47. if(TRAX_MODE == "development") {
  48. define("DEBUG", true);
  49. # Display errors to browser if in development mode for debugging
  50. ini_set("display_errors", "On");
  51. } else {
  52. define("DEBUG", false);
  53. # Hide errors from browser if not in development mode
  54. ini_set("display_errors", "Off");
  55. }
  56.  
  57. # Load databse settings
  58. $GLOBALS['TRAX_DB_SETTINGS'] = parse_ini_file(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['config']."/database.ini",true);
  59.  
  60. # Should we use local copy of the Trax libs in vendor/trax or
  61. # the server Trax libs in the php libs dir defined in PHP_LIB_ROOT
  62. if(file_exists(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['vendor']."/trax")) {
  63. define("TRAX_LIB_ROOT", TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['vendor']."/trax");
  64. } elseif(file_exists(PHP_LIB_ROOT."/trax")) {
  65. define("TRAX_LIB_ROOT", PHP_LIB_ROOT."/trax");
  66. } else {
  67. echo "Can't determine where your Trax Libs are located.";
  68. exit;
  69. }
  70.  
  71. # Set the include_path
  72. ini_set("include_path",
  73. ".".TRAX_PATH_SEPERATOR. # current directory
  74. TRAX_LIB_ROOT.TRAX_PATH_SEPERATOR. # trax libs (vendor/trax or server trax libs)
  75. PHP_LIB_ROOT.TRAX_PATH_SEPERATOR. # php libs dir (ex: /usr/local/lib/php)
  76. TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['lib'].TRAX_PATH_SEPERATOR. # app specific libs extra libs to include
  77. ini_get("include_path")); # add on old include_path to end
  78.  
  79. # Include Trax library files.
  80. include_once("session.php");
  81. include_once("input_filter.php");
  82. include_once("trax_exceptions.php");
  83. include_once("inflector.php");
  84. include_once("active_record.php");
  85. include_once("action_view.php");
  86. include_once("action_controller.php");
  87. include_once("action_mailer.php");
  88. include_once("dispatcher.php");
  89. include_once("router.php");
  90.  
  91. # Include the ApplicationMailer Class which extends ActionMailer for application specific mailing functions
  92. if(file_exists(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['app']."/application_mailer.php")) {
  93. include_once(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['app']."/application_mailer.php");
  94. }
  95.  
  96. # Include the application environment specific config file
  97. if(file_exists(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['environments']."/".TRAX_MODE.".php")) {
  98. include_once(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['environments']."/".TRAX_MODE.".php");
  99. }
  100.  
  101. ##############################################
  102. # Auto include model / controller / other app specific libs files
  103. ##############################################
  104. function __autoload($class_name) {
  105. $file = Inflector::underscore($class_name).".php";
  106. $file_org = $class_name.".php";
  107.  
  108. if(file_exists(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['models']."/$file")) {
  109. # Include model classes
  110. include_once(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['models']."/$file");
  111. } elseif(file_exists(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['controllers']."/$file")) {
  112. # Include extra controller classes
  113. include_once(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['controllers']."/$file");
  114. } elseif(file_exists(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['lib']."/$file")) {
  115. # Include users application libs
  116. include_once(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['lib']."/$file");
  117. } elseif(file_exists(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['lib']."/$file_org")) {
  118. # Include users application libs
  119. include_once(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['lib']."/$file_org");
  120. }
  121. }
  122.  
  123. ?>

Documentation generated on Thu, 06 Apr 2006 10:58:37 -0600 by phpDocumentor 1.3.0RC4