Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/php-strict/script-runner
Class for running separate processes of PHP CLI scripts
https://github.com/php-strict/script-runner
multiprocessing php php-library php7 runner script
Last synced: about 2 months ago
JSON representation
Class for running separate processes of PHP CLI scripts
- Host: GitHub
- URL: https://github.com/php-strict/script-runner
- Owner: php-strict
- License: gpl-3.0
- Created: 2020-04-30T14:34:24.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-06-03T12:44:13.000Z (7 months ago)
- Last Synced: 2024-10-28T07:33:29.433Z (about 2 months ago)
- Topics: multiprocessing, php, php-library, php7, runner, script
- Language: PHP
- Size: 26.4 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Script runner
[![Software License][ico-license]](LICENSE.txt)
[![Build Status][ico-travis]][link-travis]
[![codecov][ico-codecov]][link-codecov]
[![Codacy Badge][ico-codacy]][link-codacy]Class for running PHP CLI script in several separate processes.
## Requirements
* PHP >= 7.1
## Install
Use class as standalone:
```php
require 'ScriptRunner.php';
use PhpStrict\ScriptRunner\ScriptRunner;
```Install with [Composer](http://getcomposer.org):
```bash
composer require php-strict/script-runner
```## Usage
```php
use PhpStrict\ScriptRunner\ScriptRunner;//params: path_to_script, processes count (if omitted then system CPU cores count will be used)
$sr = new ScriptRunner('script.php', 4);
$sr->run();
```May be used with [CooperativeWorker](https://github.com/php-strict/cooperative-worker)
to split one sequential process into several separated processes and keep them from collisions
and making the same job twice.
For eaxample it is possible to convert process of parsing log files from cycle (where log files parsing one-by-one)
into several separated processes where each process take job from common temporary storage (queue).## Tests
To execute the test suite, you'll need [Codeception](https://codeception.com/).
```bash
vendor/bin/codecept run
```[ico-license]: https://img.shields.io/badge/license-GPL-brightgreen.svg?style=flat-square
[ico-travis]: https://img.shields.io/travis/php-strict/script-runner/master.svg?style=flat-square
[link-travis]: https://travis-ci.org/php-strict/script-runner
[ico-codecov]: https://codecov.io/gh/php-strict/script-runner/branch/master/graph/badge.svg
[link-codecov]: https://codecov.io/gh/php-strict/script-runner
[ico-codacy]: https://app.codacy.com/project/badge/Grade/7c78e2d59fce46e78fb65160dc530bd3
[link-codacy]: https://www.codacy.com/gh/php-strict/script-runner?utm_source=github.com&utm_medium=referral&utm_content=php-strict/script-runner&utm_campaign=Badge_Grade