gonzalo123 / sh
命令行助手
v1.0
2012-12-03 09:22 UTC
Requires
- php: >=5.3.0
- symfony/process: dev-master
This package is not auto-updated.
Last update: 2024-09-14 13:05:18 UTC
README
PHP 的命令行库,允许将程序作为函数调用。
灵感来源于 Python Sh 库(http://amoffat.github.com/sh/)
使用示例
<?php error_reporting(-1); // include PSR-0 autoloader include __DIR__ . '/../vendor/autoload.php'; use Sh\Sh; // Simple command using factory echo Sh::factory()->runCommand('notify-send', array('-t', 5000, 'title', 'HOLA')); // with instance $sh = new Sh(); echo $sh->ifconfig("eth0"); echo $sh->ls('-latr ~'); echo $sh->ls(array('-latr', '~')); $sh->tail('-f /var/log/apache2/access.log', function ($buffer) { echo $buffer; }); // chainable commands (baking) $sh->ssh(array('myserver.com', '-p' => 1393))->whoami(); // executes: ssh myserver.com -p 1393 whoami $sh->ssh(array('myserver.com', '-p' => 1393))->tail(array("/var/log/dumb_daemon.log", 'n' => 100)); // executes: ssh myserver.com -p 1393 tail /var/log/dumb_daemon.log -n 100 });
Composer 需求
"require":{
"gonzalo123/sh": "v1.0",
"symfony/process":"dev-master"
},`