phore/system

执行shell命令

v1.1.0 2022-10-21 23:12 UTC

This package is auto-updated.

Last update: 2024-09-09 18:59:06 UTC


README

本文档遵循infracamp项目中讨论的教育级别文档指南编写。请提出并记录问题。

目标

  • exec()周围的安全且易于使用的包装器

快速入门

phore_exec

$return = phore_exec("ls -l :path", ["path"=>"some Path "])
echo $return;

phore_proc

  • 读取STDOUT/STDERR
$result = phore_proc("ls -l *", ["/some/path"])->wait();
echo "\nStderr: " . $result->getSTDERRContents(); 
echo "\nStdOut: " . $result->getSTDOUTContents();
  • 读取流
$result = phore_proc("ls -l *", ["/some/path"])
    ->watch(1, function ($data, $len, PhoreProc $proc) use () {
        if ($data === null) {
            echo "End of stream";
            return;
        }
        echo "Steam in: $data";
    })->wait();
echo "\nStderr: " . $result->getSTDERRContents(); 

安装

我们建议使用composer

composer require phore/system