如何在yii命令行操作中获取bash命令


How to get bash command in yii cli action?

class RunCommand extends CConsoleCommand
{
    public function actionIndex($site, array $filters = null)
   {
      //here i need the command
   }
}

和调用(我需要在操作中的命令):

php yiic run --site=index --filers=mobiles --filers=tvs

在yiic.php中配置配置文件和框架的路径:

<?php
// change the following paths if necessary
$yiic=dirname(__FILE__).'/../../framework/yiic.php';
$config=dirname(__FILE__).'/config/console.php';
require_once($yiic);

之后,您可以使用./yiicphp yiic.php来运行控制台命令。基本命令为:

class RunCommand extends CConsoleCommand
{
    public function run($args)
    {
      //here $args will have your params, just parse them:
      // $args[0] => --site=index, $args[1] => --filers=mobiles etc...
      //here i need the command
    }
}

然后运行你的命令,如果一切ok, ./yiic run --site=index --filers=mobiles --filers=tvsphp yiic.php run --site=index --filers=mobiles --filers=tvs