当前位置:网站首页>[mikehaertl/php-shellcommand] A library for invoking external command operations
[mikehaertl/php-shellcommand] A library for invoking external command operations
2022-08-02 03:55:00 【phpreturn】
It provides a simple method interface to call and manipulate external commands, which can be used to replace exec.
Compared with calling exec directly, it has the following features:
- Capture, stdOut, stdErr, exitCode
- Handling complex parameters
- Support environment variables and other parameters
- Support for pipeline resources, such as files or streams
- Timeout can be executed
Basic usage
execute()) {echo $command->getOutput();} else {echo $command->getError();$exitCode = $command->getExitCode();}Advanced usage
Add parameter
addArg('--name=', "d'Artagnan");// Add argument with several values// results in --keys key1 key2$command->addArg('--keys', array('key1','key2'));String input
setStdIn('{"foo": 0}');if (!$command->execute()) {echo $command->getError();} else {echo $command->getOutput();}// Output:// {// "foo": 0// }Use file content as input
setStdIn($fh);if (!$command->execute()) {echo $command->getError();} else {echo $command->getOutput();}fclose($fh);Take URL content as input
setStdIn($fh);if (!$command->execute()) {echo $command->getError();} else {echo $command->getOutput();}fclose($fh);Encapsulate the command
'/usr/local/bin/mycommand',// Will be passed as environment variables to the command'procEnv' => array('DEMOVAR' => 'demovalue'),// Will be passed as options to proc_open()'procOptions' => array('bypass_shell' => true,),));Support more parameter methods
Support how many methods we need to call external command book, such as getting output, getting error, getting exit code, etc.
边栏推荐
- 面试总结 22/7/22 面试中的重点
- [vite] Failed to parse source for import analysis because the content contains invalid JS syntax.
- 三月底啦啦
- Thread Pool (Introduction and Use of Thread Pool)
- [mikehaertl/php-shellcommand]一个用于调用外部命令操作的库
- (6) 学生信息管理系统设计
- vue3 访问数据库中的数据
- [phpunit/php-timer]一个用于代码执行时间的计时器
- 12.什么是JS
- 微信小程序怎么批量生成带参数的小程序码?
猜你喜欢

1.uview form校验位置可以改变 2.时间区间

MySql高级 -- 约束

ES6介绍+定义变量+不同情况下箭头函数的this指向

v-bind用法:类动态绑定对象 数组 style样式 及函数方法

IO stream, encoding table, character stream, character buffer stream

微信小程序云开发之券码领取,怎么防止用户领取到相同的数据?

js __proto__、prototype、constructor的关系

5.19今日学习

The querystring module

SQL: DDL, DML, DQL, DCL corresponding introduction and demonstration
随机推荐
关于tp的apache 的.htaccess文件
多线程(实现多线程、线程同步、生产者消费者)
PHP 发起支付宝支付时 订单信息乱码解决
点名系统和数组元素为对象的排序求最大值和最小值
1.8今日学习
微信小程序自定义swiper轮播图面板指示点|小圆点|进度条
js 之 Object.defineProperty()
宝塔邮局邮箱设置成功后能发送不能接收问题处理
When PHP initiates Alipay payment, the order information is garbled and solved
线程池(线程池介绍与使用)
QR code generation API interface, which can be directly connected as an A tag
PHP图片压缩到指定的大小
每日五道面试题 2022/7/27
解决uni-app 打包H5网站 下载图片问题
IO stream, encoding table, character stream, character buffer stream
The Error in the render: "TypeError: always read the properties of null '0' (reading)" Error solution
Small program van-cell line wrapping can be left-aligned
[campo/random-user-agent]随机伪造你的User-Agent
v-on基本使用、参数传递、修饰词
js takes the value of a feature at a certain position in the string, such as Huawei=> Huawei