{"id":15916890,"url":"https://github.com/takuya/php-process","last_synced_at":"2025-08-28T23:45:34.362Z","repository":{"id":54018482,"uuid":"247007584","full_name":"takuya/php-process","owner":"takuya","description":"php proc_open wrapper class for shell command process.","archived":false,"fork":false,"pushed_at":"2024-11-27T17:31:51.000Z","size":154,"stargazers_count":6,"open_issues_count":5,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-19T03:11:16.612Z","etag":null,"topics":["php-library","php7","pipe","process","processing","shell"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/takuya.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-13T06:59:32.000Z","updated_at":"2024-11-27T17:31:55.000Z","dependencies_parsed_at":"2022-08-13T06:01:14.202Z","dependency_job_id":null,"html_url":"https://github.com/takuya/php-process","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takuya%2Fphp-process","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takuya%2Fphp-process/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takuya%2Fphp-process/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takuya%2Fphp-process/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/takuya","download_url":"https://codeload.github.com/takuya/php-process/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245227436,"owners_count":20580883,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php-library","php7","pipe","process","processing","shell"],"created_at":"2024-10-06T18:06:19.839Z","updated_at":"2025-03-24T07:31:43.872Z","avatar_url":"https://github.com/takuya.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"php-Process for proc_open\n=================\n\nThe Process class component executes command in proc_open.\n\n\n\nNEW packages -\u003e [php-Process-exec](https://github.com/takuya/php-process-exec)\n====\n## Caution !\n\nI re-write this package and split into two package.\n\n- [php-Process](https://github.com/takuya/php-process-exec) Process handler class\n- [ProcOpen](https://github.com/takuya/php-proc_open-wrapper) proc_open wrapper class \n\nplease use these class. instead of using this packages.\n\nThis package intended to be used as SINGLE-FILE not complicated composer package.\n\n\nSample\n------\n```php\n\u003c?php\n\n$proc1 = new Process('sh');\n\n$fd_out = $proc1-\u003esetInput('echo HelloWorld')\n  -\u003epipe('cat')\n  -\u003epipe('cat')\n  -\u003epipe(['grep', 'Hello'])\n  -\u003ewait();\n\n$ret = stream_get_contents($fd_out);\n\n```\n\n[ → READ More Sample for usage ](https://github.com/takuya/php-process/blob/master/samples/README.md)\n\nInstallation\n----\n```sh\ncomposer require takuya/process\n```\n\nFeatures\n----\n\n### Buffered IO stream for STDOUT/STDERR\n\nProcess will return buffered IO for read/write\n\nMethod will return stream.\n\n```php\n\n\u003c?php\n$proc = new Process(['echo', 'HelloWorld']);\n$fd_out = $proc-\u003erun();\n\n$output = stream_get_contents($fd_out);\n// you can reuse, re-read output  \nfseek($fd_out,0);\n$str = stream_get_contents($fd_out);\n```\n### Pseudo-thread style programming\n```php\n\u003c?php\n$proc = new Process('sh sleep.sh');\n$proc-\u003estart();\necho 'started';\n$proc-\u003ejoin();\n```\n\n\n### Chain Method for Pipe Command\n\nProcess#pipe() can PIPE programs.\n\nImplicite connect pipe stdout -\u003e stdin\n```php\n\n\u003c?php\n$proc = new Process(['echo', 'HelloWorld']);\n$fd_out =  $proc-\u003epipe('cat')\n            -\u003epipe('cat')\n            -\u003epipe('cat')\n            -\u003epipe('cat')\n            -\u003ewait();\n```\nExplicitly Pipe,  connect (Proc1#)stdout -\u003e (Proc2#)stdin\n```php\n\u003c?php\n$proc1 = new Process(['echo', 'HelloWorld']);\n$proc2 = new Process(['cat']);\n[$p1_out,$p1_err] = $proc1-\u003estart();\n$proc2-\u003esetInput($p1_out);\n$proc2-\u003estart();\n$proc2-\u003ewait();\n$proc1-\u003ewait();\n```\nNotice: `$proc2-\u003ewait()` call first, to avoid long locking , to run two process in parallel.\nThe reason is `Process` class adopt implied IOBuffering at `wait`, so `calling wait()` means that runs stream buffering loop until process end.\n\n### A Simple way, Only Single File for use.\n\nNo extra packages required.\n\nA Single File `src/Process.php` need to use. just write require_once like this.\n\n```php\n\n\u003c?php\nrequire_once 'src/Process.php';\n\n``` \n\nThis `Process class` is written by ***vanilla php***. No extra packages. No pear, No composer, No other packages need to install.  \nUsing this without `composer.phar` or other Package manager, all you need is Just write require_once.\n \n\n\nMore Samples\n---\n\n\nMore Usage , Read files in this procjet `/samples`, `/tests/Features`  and `./docs`.\n\n\nResources\n---------\n\n  * [Documentation](https://github.com/takuya/php-process/blob/master/docs/procss.funcs.md)\n  * [Contributing](https://github.com/takuya/php-process/)\n  * [Report issues](https://github.com/takuya/php-process/issues) and\n    [send Pull Requests](https://github.com/takuya/php-process/pulls)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakuya%2Fphp-process","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftakuya%2Fphp-process","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakuya%2Fphp-process/lists"}