thelfensdrfer / yii-ssh-console
yii 控制台命令的 SSH 库
1.2.1
2017-03-08 15:19 UTC
Requires
- php: >=5.5.0
- phpseclib/phpseclib: 2.0.*
- yiisoft/yii: *
This package is auto-updated.
Last update: 2024-09-06 08:27:17 UTC
README
提供 ssh 命令的 yii 控制台控制器。
示例
<?php class DeployCommand extends CConsoleCommand { public $defaultAction = 'exec'; public function actionExec() { $this->auth('example.com', [ 'username' => 'myusername', 'password' => 'mypassword', // optional ]); // Or via private key /* $this->auth('example.com', [ 'username' => 'myusername', 'key' => '/path/to/private.key', 'password' => 'mykeypassword', // optional ]); */ $output = $this->run('echo "test"'); echo 'Output: ' . $output; // Output: test $output = $this->run([ 'cd /path/to/install', './put_offline.sh', 'git pull -f', 'composer install', './yii migrate --interactive=0', './build.sh', './yii cache/flush', './put_online.sh', ]); // Or via callback $this->run([ 'cd /path/to/install', './put_offline.sh', 'git pull -f', 'composer install', './yii migrate --interactive=0', './build.sh', './yii cache/flush', './put_online.sh', ], function($line) { echo $line; }); } }
然后在本地控制台中
./yiic deploy