loandbeholdru / pipe
用于运行Linux管道的shell命令的类
dev-master
2023-06-05 20:26 UTC
Requires
- php: >=7.0
This package is auto-updated.
Last update: 2024-10-01 00:07:30 UTC
README
这是一个小巧轻量的包装,可以运行通过命令管道(总线)传递的shell脚本。因此,它非常适合在docker-container上构建webhooks,并使用REST API将它们链接起来。
您不再需要学习复杂的webhooks包配置。使用常用工具即可。
安装
建议使用 Composer 来安装shorts。
$ composer require loandbeholdru/pipe
使用方法
使用php在主机上创建管道,并赋予在执行脚本的主机上读取它的权限(docker-composer示例)
mkfifo /tmp/pipefile
在具有shell脚本的宿主/容器上运行主要执行 脚本
./serve.sh [path_to_pipe] [path_to_reaction_dir]
创建命令
$command = new pipecommand("/tmp/pipefile", "/some/path/script_with_two_params.sh %s %s", $par1, $par2);
创建结果陷阱
$result = new piperesult("/tmp/pipefile", new brokenPipeException("When pipe not working!"));
执行您的命令并从您的shell脚本中获取$strings
$strings = pipe::exec($command, $result, new bashCommandErrorException("When your script return error!"));
贡献
... 总是受欢迎的。很多时候,仅仅指出作者未曾考虑或遇到的用例就很有用。