Download the PHP package takuya/php-proc_open-wrapper without Composer
On this page you can find all versions of the php package takuya/php-proc_open-wrapper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download takuya/php-proc_open-wrapper
More information about takuya/php-proc_open-wrapper
Files in takuya/php-proc_open-wrapper
Package php-proc_open-wrapper
Short Description proc_open wrapper to exec command.
License GPL-3.0-or-later
Informations about the package php-proc_open-wrapper
Run Process.
Run process and run string by interpreter(ex.python,bash). and keep process long time task running.
proc_open
is distinctive style. so I make proc_open
EASY and friendly.
Installing
from packagist.
from GitHub repos.
check installation.
sample.php
run.
wait long time process.
comparison proc_open , ProcOpen.
compare proc_open(original) , ProcOpen(this package) in using.
- process (no input)
- process (with stdin,stderr,stdout )
- process (read output)
- process (pipe line)
simple (no input, no stdout)
proc_open
ProcOpen Wrapper(this package)
simple ( with stdin,stderr,stdout )
proc_open
ProcOpen Wrapper (this package)
simple ( read output )
Open php Interactive Shell (php -a
) and write and read out
proc_open
: Do as above.
ProcOpen
Wrapper
sample pipe( String and Shell )
proc_open
is accept string $cmd
but not safe.
ProcOpen
wrapper, shell call and pipe io
``
Test
phpunit
examples
See Examples.
safer process call
This package directly exec command, not using 'shell'.
proc_open executes command directly, without shell ( fork then exec ).
Using proc_open correctly, directory traversal
vulnerability , shell injection
vulnerability will not be occurred. Shell escaping will not be needed. this can reduce risks.
Don't escape string , use array.
use cmd array. not escaping.
proc_open can accept cmd string, but cmd string may be danger(mal-escaping). exec cmd by array is more safe.
you must check arguments.
To prevent directory traversal. you must check args in advance. cmd string cannot be checked, but array can check.
pipe process
Make easy to pipe process by proc_open.
pipe by pure php. It's very painful.
Use this ProcOpen class , reduce cost by naturally call proc_open.
Run string as shell script.
Run string as python code.
run python code in proc_open
Run php interactive shell php -a
wait() is not always needed.
read output will be Blocked by OS until process end. Proc#wait
is not always needed.
ProcOpen has shortcut by function
Linux pipe max.
Linux pipe will be Stuck(blocked) if left unread.
LINUX_PIPE_SIZE
is 1024*64
.
so if you try to write one more byte (1024*64+1
bytes) to stdout
, process will be blocked by OS.
To avoid BUFF stuck use blockingIO instead of wait.
or, To avoid blocking, you can use tmp-io.
Or use select syscall
and read the buffer.
'php://temp' may be looks good, but that is not all good. It will be cast to TEMP FILE.
To use fopen wrapppers , flag the property before start.