common.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. // 根路径 ROOT_PATH 定义, 5.3以后可以直接使用__DIR__
  3. // 所有被包含文件均须使用此常量确定路径
  4. define('ROOT_PATH', realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR);
  5. define('BASE_DIR', ROOT_PATH . '/../');
  6. define('ENV_LOCAL', 'local');
  7. define('ENV_DEV', 'dev');
  8. define('ENV_FORMAL', 'form');
  9. define('ENV_NEW', 'new');
  10. $fileName = __FILE__;
  11. // 仅仅用于IDE代码提示
  12. if (false) {
  13. define('FRAMEWORK_PATH', BASE_DIR . '../../framework/phpbase2/');
  14. } else if (strpos($fileName, '/data/webapps/') === 0 ) {
  15. if (strpos($fileName, '/test.') !== false || strpos($fileName, '/test-') !== false || strpos($fileName, '_test/') !== false) {
  16. define('CONF_PATH', '/data/webapps/conf_v2/test/');
  17. define('FRAMEWORK_PATH', '/data/webapps/framework/phpbase2_test/');
  18. $env = ENV_DEV;
  19. } elseif (strpos($fileName, '/new.') !== false || strpos($fileName, '/new-') !== false || strpos($fileName, '_new/') !== false) {
  20. define('CONF_PATH', '/data/webapps/conf_v2/new/');
  21. define('FRAMEWORK_PATH', '/data/webapps/framework/phpbase2_new/');
  22. $env = ENV_NEW;
  23. } else {
  24. define('CONF_PATH', '/data/webapps/conf_v2/form/');
  25. define('FRAMEWORK_PATH', '/data/webapps/framework/phpbase2/');
  26. $env = ENV_FORMAL;
  27. }
  28. } else if (strpos($fileName, '/data_dev/') === 0 ) {
  29. // 内网开发环境
  30. define('CONF_PATH', '/data/webapps/conf_v2/test/');
  31. $local = BASE_DIR . '../../framework/phpbase2/';
  32. if (file_exists($local)) {
  33. define('FRAMEWORK_PATH', $local);
  34. } else {
  35. define('FRAMEWORK_PATH', '/data/webapps/framework/phpbase2_test/');
  36. }
  37. // 标识为内网开发环境,使用内网服务器的redis
  38. // $GLOBALS['IS_WEB_DEV'] = true;
  39. $env = ENV_DEV;
  40. } else {
  41. // 本地环境
  42. // define('FRAMEWORK_PATH', BASE_DIR . '../../framework/phpbase2/');
  43. define('FRAMEWORK_PATH', BASE_DIR . '../../php_new/trunk/framework/phpbase2/');
  44. // define('CONF_PATH', FRAMEWORK_PATH . 'protected/conf/conf_ns/');
  45. define('CONF_PATH', '/data/webapps/conf_v2/test/');
  46. define('IS_ENV_LOCAL', true);
  47. $env = ENV_DEV;
  48. }
  49. require_once FRAMEWORK_PATH . 'protected/common.php';
  50. //require_once __DIR__ . '/vendor/autoload.php';