index.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. // phpinfo();
  3. // exit;
  4. header("Content-Type:text/html;charset=utf-8");
  5. date_default_timezone_set('PRC'); // Asia/Shanghai
  6. // change the following paths if necessary
  7. $yii=dirname(__FILE__).'/framework/yii.php';
  8. if (isset($_SERVER['YII_ENV']))
  9. {
  10. define('YII_ENV', $_SERVER['YII_ENV']);
  11. }
  12. else
  13. {
  14. define('YII_ENV', 'development');
  15. }
  16. // 增加 APPLICATION_ENV 本地公用配置
  17. if (defined("YII_ENV") && file_exists(dirname(__FILE__) .'/protected/config/main.'. YII_ENV .'.php')) {
  18. $publicConfig = dirname(__FILE__) .'/protected/config/main.'. YII_ENV .'.php';
  19. } else {
  20. $publicConfig = dirname(__FILE__).'/protected/config/main.php';
  21. }
  22. /*
  23. *---------------------------------------------------------------
  24. * 错误报告
  25. *---------------------------------------------------------------
  26. *
  27. * 不同的环境需要不同程度的错误报告
  28. * 开发环境会显示错误报告, 测试及生产环境会隐藏错误报告
  29. */
  30. if (defined('YII_ENV')){
  31. switch (YII_ENV) {
  32. case 'local':
  33. @ini_set('display_errors', TRUE);
  34. error_reporting(-1);
  35. break;
  36. case 'development':
  37. @ini_set('display_errors', TRUE);
  38. error_reporting(E_ALL);
  39. //defined('YII_DEBUG') or define('YII_DEBUG',true);
  40. break;
  41. case 'testing':
  42. @ini_set('display_errors', TRUE);
  43. //报告运行时错误
  44. error_reporting(-1);
  45. //defined('YII_DEBUG') or define('YII_DEBUG',true);
  46. break;
  47. case 'production':
  48. error_reporting(0);
  49. break;
  50. default:
  51. exit(json_encode(array('code' => 500, 'message' => 'System environment settings are not correct!')));
  52. }
  53. }
  54. // remove the following lines when in production mode
  55. defined('YII_DEBUG') or define('YII_DEBUG',true);
  56. // specify how many levels of call stack should be shown in each log message
  57. defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
  58. //配置文件存储路径
  59. $configFile=dirname(__FILE__).DIRECTORY_SEPARATOR.'protected'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'cache';
  60. $config =$configFile.DIRECTORY_SEPARATOR.'main.'.YII_ENV.'.php';;
  61. if (! file_exists($config)) {
  62. $config=$publicConfig;
  63. }
  64. // 加载自定义函数
  65. require_once(dirname(__FILE__) . '/protected/config/my_functions.php');
  66. require_once($yii);
  67. require_once(dirname(__FILE__) .'/protected/helper/yii.php');
  68. Yii::createWebApplication($config)->run();