yiic.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. // 设置页面编码
  3. //header('Content-Type: text/html; charset=utf-8');
  4. // 设置时区
  5. //date_default_timezone_set('Asia/Chongqing');
  6. // fix for fcgi
  7. defined('STDIN') OR define('STDIN', fopen('php://stdin', 'r'));
  8. defined('YII_DEBUG') OR define('YII_DEBUG', TRUE);
  9. $YII_ENV = '';
  10. if ($argc AND $argv)
  11. {
  12. foreach ($argv AS $k => $v)
  13. {
  14. if ($k >= 3)
  15. {
  16. if (substr($v, 0, 10) == '--YII_ENV=')
  17. {
  18. $YII_ENV = trim(substr($v, 10));
  19. break;
  20. }
  21. }
  22. }
  23. }
  24. if (empty($YII_ENV)){
  25. $YII_ENV = 'production';
  26. }
  27. define('YII_ENV', $YII_ENV);
  28. // change the following paths if necessary
  29. $yii = dirname(__FILE__) .'/../../framework/yii.php';
  30. $config = dirname(__FILE__) .'/../config/console.'. $YII_ENV .'.php';
  31. if ( ! file_exists($config)) exit('Configuration file does not exist!');
  32. require_once($yii);
  33. require_once(dirname(__FILE__) .'/../helper/yii.php');
  34. if(isset($config))
  35. {
  36. $app = Yii::createConsoleApplication($config);
  37. // $app->commandRunner->addCommands(YII_PATH .'/cli/commands');
  38. $app->commandRunner->addCommands(dirname(dirname(__FILE__)) .'/commands');
  39. }
  40. else
  41. {
  42. // $app = Yii::createConsoleApplication(array('basePath' => dirname(__FILE__) .'/cli'));
  43. $app = Yii::createConsoleApplication(array('basePath' => dirname(dirname(__FILE__)) .'/commands'));
  44. }
  45. $env = @getenv('YII_CONSOLE_COMMANDS');
  46. if( ! empty($env))
  47. {
  48. $app->commandRunner->addCommands($env);
  49. }
  50. $app->run();