tjm / shell-runner
通过ssh或本地方式从PHP运行shell命令。
v0.0.14
2023-10-03 20:44 UTC
Requires
- php: >=5.3.3
- symfony/process: >=2.4 <7.0
README
本地或通过SSH运行shell命令。主要用于简化在远程机器上运行命令,无论是交互式还是捕获输出。
用法
通过composer安装。示例用法
<?php use TJM\ShellRunner\ShellRunner; $shell = new ShellRunner(); //--run `ls` locally, capturing output $output = $shell->run(Array( 'command'=> 'ls' )); //--run `ls` remotely, capturing output $output = $shell->run(Array( 'command'=> 'ls' ,'host'=> 'tobymackenzie.com' )); //--SSH into remote machine interactively. Will not capture output. Interaction will require running PHP on command line, not in browser. $shell->run(Array( 'host'=> 'tobymackenzie.com' ,'interactive'=> true ));
其他选项
- PHP内置函数
- Symfony Process组件(该项目在某些情况下使用)
- PHP安全通信库
- PHP Secure Shell2扩展