Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/norberttech/symfony-process-executor

💻 Symfony Process Component on steroids, async/sync execution chain.
https://github.com/norberttech/symfony-process-executor

execution parallel process symfony

Last synced: 5 days ago
JSON representation

💻 Symfony Process Component on steroids, async/sync execution chain.

Awesome Lists containing this project

README

        

# Symfony Process Executor

![Tests](https://github.com/norberttech/symfony-process-executor/workflows/Tests/badge.svg?branch=2.x)

Tiny library that simplifies launching multiple processes in parallel (or not).

### Installation

```bash
composer require norberttech/symfony-process-executor
```

### Examples

```php
execute();

$executor->waitForAllToFinish();

$executor->pool()->each(function (ProcessWrapper $processWrapper) {
var_dump($processWrapper->exitCode());
var_dump(\trim($processWrapper->output()));
var_dump($processWrapper->executionTime()->inSeconds());
var_dump($processWrapper->executionTime()->inMilliseconds());
var_dump($processWrapper->executionTime()->microsecond());
echo "----\n";
});

echo \sprintf("Successfully finished child processes: %d\n", $executor->pool()->withSuccessExitCode());
echo \sprintf("Failure finished child processes: %d\n", $executor->pool()->withFailureExitCode());
echo \sprintf("Total execution time [s]: %d\n", $executor->executionTime()->inSecondsPreciseString());
```

Output:

```bash
php examples/async_multiple_success_processes.php

int(0)
string(1) "1"
int(1)
int(1033)
int(1033295)
----
int(0)
string(1) "2"
int(2)
int(2064)
int(2064680)
----
int(0)
string(1) "3"
int(3)
int(3092)
int(3092137)
----
int(0)
string(1) "4"
int(4)
int(4026)
int(4026060)
----
int(0)
string(1) "5"
int(5)
int(5052)
int(5052531)
----
Successfully finished child processes: 5
Failure finished child processes: 0
Total execution time [s]: 5
```

## Tests

All tests for this library are written as phpt files, you can read more about it here https://qa.php.net/phpt_details.php.

In order to launch full testsuite use composer

```php
composer tests
```