{"id":20719711,"url":"https://github.com/slince/process","last_synced_at":"2025-04-23T14:25:00.548Z","repository":{"id":57053328,"uuid":"88350901","full_name":"slince/process","owner":"slince","description":":whale2: The process wrapper and manager  based on PCNTL on the Unix-like systems using php","archived":false,"fork":false,"pushed_at":"2023-10-13T15:28:14.000Z","size":78,"stargazers_count":22,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-30T00:31:38.323Z","etag":null,"topics":["child-process","fifo","fork","pcntl","pipe","posix","process","semaphore","shared-memory","system-v"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/slince.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-04-15T14:08:55.000Z","updated_at":"2023-10-13T12:10:51.000Z","dependencies_parsed_at":"2023-10-15T03:34:50.882Z","dependency_job_id":null,"html_url":"https://github.com/slince/process","commit_stats":{"total_commits":41,"total_committers":3,"mean_commits":"13.666666666666666","dds":"0.19512195121951215","last_synced_commit":"2aa5db0a4e81652543ea304ba2e198c07e786fcd"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slince%2Fprocess","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slince%2Fprocess/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slince%2Fprocess/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slince%2Fprocess/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slince","download_url":"https://codeload.github.com/slince/process/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250449608,"owners_count":21432494,"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":["child-process","fifo","fork","pcntl","pipe","posix","process","semaphore","shared-memory","system-v"],"created_at":"2024-11-17T03:18:06.092Z","updated_at":"2025-04-23T14:25:00.530Z","avatar_url":"https://github.com/slince.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Process Library\n\n[![Build Status](https://img.shields.io/github/actions/workflow/status/slince/process/test.yml?style=flat-square)](https://github.com/slince/process/actions)\n[![Coverage Status](https://img.shields.io/codecov/c/github/slince/process.svg?style=flat-square)](https://codecov.io/github/slince/process)\n[![Total Downloads](https://img.shields.io/packagist/dt/slince/process.svg?style=flat-square)](https://packagist.org/packages/slince/process)\n[![Latest Stable Version](https://img.shields.io/packagist/v/slince/process.svg?style=flat-square\u0026label=stable)](https://packagist.org/packages/slince/process)\n[![Scrutinizer](https://img.shields.io/scrutinizer/g/slince/process.svg?style=flat-square)](https://scrutinizer-ci.com/g/slince/process/?branch=master)\n\nThe library help to work with processes. It provides a more readable api and various modes for IPC via pipe(FIFO) and system v. \n\n# Installation\n\nInstall via composer\n\n```bash\ncomposer require slince/process\n```\n\n# Dependencies\n\nThe library replies on the following php's extension.\n\n- ext-pcntl. Provides control processes (MUST)\n- ext-sysvshm. Porvides system v shared memory (OPTIONAL)\n- ext-sysvsem. Porvides system v semaphore (OPTIONAL)\n- ext-sysmsg. Porvides system v message queue (OPTIONAL)\n\n# Usage\n\n## Basic usage \n\n```php\n$process = new Slince\\Process\\Process(function(){\n    echo 'hello, my pid is ' . getmypid();\n});\n$process-\u003estart();\n\nvar_dump($process-\u003eisRunning()); // echo true\nvar_dump($process-\u003egetPid()); // will output the pid of child process\n//do something other\n\n$process-\u003ewait(); //waiting for the process to exit \n```\n\n## Sends signal to the process\n\n\u003eNote: If your php version is less than 7.1, please add the statement `declare(ticks=1);` at the beginning of the file:\n\n```php\n$process = new Slince\\Process\\Process(function(){\n    Slince\\Process\\Process::current()-\u003esignal([SIGUSR1, SIGUSR2], function(){\n        echo 'trigger signal';\n    });\n    echo 'hello, my pid is ' . getmypid();\n});\n$process-\u003estart();\n$process-\u003esignal(SIGUSER1);\n//do something\n$process-\u003ewait();\n```\n\n## Shared memory\n\n```php\n$memory = new Slince\\Process\\SystemV\\SharedMemory();\n$memory-\u003eset('foo', 'bar');\nvar_dump($memory-\u003eget('foo'));\n```\nThe default size of shared memory is the sysvshm.init_mem in the php.ini, otherwise 10000 bytes. You can adjust this.\n\n```php\n$memory = new Slince\\Process\\SystemV\\SharedMemory(__FILE__, '5M'); //Adjusts to 5m\n```\n\n## Semaphore\n```php\n$semaphore = new Slince\\Process\\SystemV\\Semaphore();\n$semaphore-\u003eacquire(); //Acquires a lock\n// do something\n$semaphore-\u003erelease() //Releases a lock\n```\n\n## Message queue\n\n```php\n$queue  = new Slince\\Process\\SystemV\\MessageQueue();\n$queue-\u003esend('hello');\necho $queue-\u003ereceive(); //Will output hello\n```\n\n## Fifo\n\n```php\n$writeFifo = new Slince\\Process\\Pipe\\WritableFifo('/tmp/test.pipe');\n$writeFifo-\u003ewrite('some message');\n$readFifo = new Slince\\Process\\Pipe\\ReadableFifo('/tmp/test.pipe');\necho $readFifo-\u003eread();\n```\n\n## License\n\nThe MIT license. See [MIT](https://opensource.org/licenses/MIT)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslince%2Fprocess","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslince%2Fprocess","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslince%2Fprocess/lists"}