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

Source for file environment.php

Documentation is available at environment.php

  1. <?php
  2. /**
  3. * Trax runtime environment definitions
  4. * @package PHPonTrax
  5. * $Id$
  6. */
  7.  
  8. /**
  9. * Location of the PEAR library on this system
  10. *
  11. * Set automatically by the Pear installer when you install Trax with
  12. * the <b>pear install</b> command. If you are prevented from using
  13. * <b>pear install</b>, change "@PHP-DIR@" by hand to the full filesystem
  14. * path of the location where you installed the Pear modules needed
  15. * by Trax.
  16. */
  17. define("PHP_LIB_ROOT", "@PHP-DIR@");
  18.  
  19. /**
  20. * Location of the directories constructed by the <b>trax</b>
  21. * command.
  22. */
  23. define("TRAX_ROOT", dirname(dirname(__FILE__)) . "/");
  24.  
  25. /**
  26. * Location of the directory exposed to the public by Apache.
  27. *
  28. * The <b>trax</b> command generates this as <i>TRAX_ROOT</i>/public/
  29. * but you will probably want to move the files in public/ to somewhere under
  30. * {@link http://httpd.apache.org/docs/2.0/ Apache}
  31. * {@link http://httpd.apache.org/docs/2.0/mod/core.html#documentroot DocumentRoot}.
  32. * Change the second argument to the full filesystem path to the
  33. * directory that holds the files generated in public/
  34. */
  35. define("TRAX_PUBLIC", dirname(dirname(dirname(__FILE__)))."/public");
  36.  
  37. /**
  38. * Part of URL between domain name and Trax application
  39. *
  40. * That part of the browser's URL after the domain name and before
  41. * the location described by <i>TRAX_PUBLIC</i>. If
  42. * <i>TRAX_PUBLIC</i> is the same as
  43. * {@link http://httpd.apache.org/docs/2.0/ Apache}
  44. * {@link http://httpd.apache.org/docs/2.0/mod/core.html#documentroot DocumentRoot},
  45. * then TRAX_URL_PREFIX is null.
  46. */
  47. define("TRAX_URL_PREFIX", null); # no trailing slash
  48.  
  49. /**
  50. * The file extension of files in app/views. Normally '.phtml'
  51. */
  52. define("TRAX_VIEWS_EXTENTION", "phtml");
  53.  
  54. /**
  55. * Trax mode of operation
  56. *
  57. * Must be one of: 'development', 'test' or 'production'.
  58. * May be set in the
  59. * {@link http://httpd.apache.org/docs/2.0/ Apache}
  60. * configuration with the
  61. * {@link http://httpd.apache.org/docs/2.0/mod/mod_env.html#setenv SetEnv}
  62. * directive. If not set there, then it must be set here.
  63. */
  64. if(isset($_SERVER) && array_key_exists('TRAX_MODE',$_SERVER)) {
  65. define("TRAX_MODE", $_SERVER['TRAX_MODE']);
  66. } else {
  67. define("TRAX_MODE", "development");
  68. }
  69.  
  70. /**
  71. * Location of Trax components relative to TRAX_ROOT
  72. * @global $GLOBALS['TRAX_INCLUDES']
  73. */
  74. $GLOBALS['TRAX_INCLUDES'] =
  75. array( "models" => "app/models",
  76. "views" => "app/views",
  77. "controllers" => "app/controllers",
  78. "helpers" => "app/helpers",
  79. "layouts" => "app/views/layouts",
  80. "config" => "config",
  81. "environments" => "config/environments",
  82. "lib" => "lib",
  83. "app" => "app",
  84. "log" => "log",
  85. "vendor" => "vendor" ); // FIXME: generated by trax cmd
  86.  
  87. /**
  88. * Set how errors are to be logged
  89. *
  90. * The 'log_errors'
  91. * {@link http://www.php.net/manual/en/ref.errorfunc.php PHP configuration setting}
  92. * determines whether PHP error messages should be sent to the
  93. * {@link http://httpd.apache.org/docs/2.0/ Apache}
  94. * {@link http://httpd.apache.org/docs/2.0/logs.html#errorlog error log}
  95. * (log_errors false) or to the log file defined in the 'error_log'
  96. * setting (log_errors true). Trax uses a different log file for
  97. * each of the three modes defined in TRAX_MODE.
  98. *
  99. * In your application you can write a message to this log file with
  100. * the call <b>error_log("</b><i>text of message</i><b>")</b>.
  101. */
  102. ini_set("log_errors", true);
  103. ini_set("error_log",
  104. TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['log']."/".TRAX_MODE.".log");
  105.  
  106. /**
  107. * Whether to generate debugging messages and send errors to the browser
  108. *
  109. * The 'display_errors'
  110. * {@link http://www.php.net/manual/en/ref.errorfunc.php PHP configuration setting}
  111. * determines whether error messages should be sent to the browser.
  112. * It should be false for production systems. DEBUG is a define that
  113. * you can test for your own purposes.
  114. */
  115. if(TRAX_MODE == "development") {
  116. define("DEBUG", true);
  117. ini_set("display_errors", "On");
  118. } else {
  119. define("DEBUG", false);
  120. ini_set("display_errors", "Off");
  121. }
  122.  
  123. /**
  124. * Load database settings from config/database.ini
  125. */
  126. $GLOBALS['TRAX_DB_SETTINGS'] =
  127. parse_ini_file(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['config']
  128. ."/database.ini",true);
  129. /**
  130. * Define location of the Trax PHP modules
  131. *
  132. * Should we use local copy of the Trax libs in vendor/trax or
  133. * the server Trax libs in the php libs dir defined in PHP_LIB_ROOT
  134. */
  135. if(file_exists(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['vendor']."/trax")) {
  136. define("TRAX_LIB_ROOT", TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['vendor']."/trax");
  137. } elseif(file_exists(PHP_LIB_ROOT."/PHPonTrax/vendor/trax")) {
  138. define("TRAX_LIB_ROOT", PHP_LIB_ROOT."/PHPonTrax/vendor/trax");
  139. } else {
  140. error_log("Can't determine where your Trax Libs are located.");
  141. exit;
  142. }
  143.  
  144. # Set the include_path
  145. ini_set("include_path",
  146. ".".PATH_SEPARATOR. # current directory
  147. TRAX_LIB_ROOT.PATH_SEPARATOR. # trax libs (vendor/trax or server trax libs)
  148. PHP_LIB_ROOT.PATH_SEPARATOR. # php libs dir (ex: /usr/local/lib/php)
  149. TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['lib'].PATH_SEPARATOR. # app specific libs extra libs to include
  150. ini_get("include_path")); # add on old include_path to end
  151.  
  152. # Include Trax library files.
  153. include_once("session.php");
  154. include_once("input_filter.php");
  155. include_once("trax_exceptions.php");
  156. include_once("inflector.php");
  157. include_once("active_record.php");
  158. include_once("action_view.php");
  159. include_once("action_controller.php");
  160. include_once("action_mailer.php");
  161. include_once("dispatcher.php");
  162. include_once("router.php");
  163.  
  164. # Include the ApplicationMailer Class which extends ActionMailer for application specific mailing functions
  165. if(file_exists(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['app']."/application_mailer.php")) {
  166. include_once(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['app']."/application_mailer.php");
  167. }
  168.  
  169. # Include the application environment specific config file
  170. if(file_exists(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['environments']."/".TRAX_MODE.".php")) {
  171. include_once(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['environments']."/".TRAX_MODE.".php");
  172. }
  173.  
  174. /**
  175. * Automatically load a file containing a specified class
  176. *
  177. * Given a class name, derive the name of the file containing that
  178. * class then load it.
  179. * @param string class_name Name of the class required
  180. */
  181. function __autoload($class_name) {
  182. $file = Inflector::underscore($class_name).".php";
  183. $file_org = $class_name.".php";
  184.  
  185. if(file_exists(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['models']."/$file")) {
  186. # Include model classes
  187. include_once(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['models']."/$file");
  188. } elseif(file_exists(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['controllers']."/$file")) {
  189. # Include extra controller classes
  190. include_once(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['controllers']."/$file");
  191. } elseif(file_exists(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['lib']."/$file")) {
  192. # Include users application libs
  193. include_once(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['lib']."/$file");
  194. } elseif(file_exists(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['lib']."/$file_org")) {
  195. # Include users application libs
  196. include_once(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['lib']."/$file_org");
  197. }
  198. }
  199.  
  200. // -- set Emacs parameters --
  201. // Local variables:
  202. // tab-width: 4
  203. // c-basic-offset: 4
  204. // c-hanging-comment-ender-p: nil
  205. // indent-tabs-mode: nil
  206. // End:
  207. ?>

Documentation generated on Thu, 04 May 2006 19:47:34 -0600 by phpDocumentor 1.3.0RC4