在远程服务器上运行Yii CConsoleCommand

时间:2014-09-28 15:47:28

标签: php yii ftp command-line-interface

我有一个问题,弄清楚如何使我的命令工作,因为我只能通过ftp访问。

行动非常简单:

public function actionRun($action = "default") {
    $this->xml = simplexml_load_file('db.xml');
    return $this->{$action}(); // executes the default() method
}

我所需要的只是以某种方式执行php index.php mycommand run,但我失去了如何。此命令只应在整个应用程序的生命周期中运行一次。

我的问题是,是否可以运行这样的命令?也许以某种方式通过php调用它?

1 个答案:

答案 0 :(得分:0)

Yii命令行命令旨在通过Yii运行。

$ cd protected
$ ./yiic --help
$ ./yiic mycommand

如果您只有ftp访问权限,那么您可能会运气不足,并且必须使用某些解决方法,例如运行cron作业,或者创建一个调用我提供的代码示例中的最后一个命令的网页。 / p>

echo exec('/my_yii_dir/protected/yiic mycommand');