Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wyrihaximus/reactphp-child-process-promise-closure
Run a closure in a child process and return the result over a promise
https://github.com/wyrihaximus/reactphp-child-process-promise-closure
child-process closure cpu-offload hacktoberfest php php7 promise reactphp
Last synced: 11 days ago
JSON representation
Run a closure in a child process and return the result over a promise
- Host: GitHub
- URL: https://github.com/wyrihaximus/reactphp-child-process-promise-closure
- Owner: WyriHaximus
- License: mit
- Created: 2017-05-28T08:11:24.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-12-03T08:30:52.000Z (12 months ago)
- Last Synced: 2024-10-23T22:39:41.358Z (20 days ago)
- Topics: child-process, closure, cpu-offload, hacktoberfest, php, php7, promise, reactphp
- Language: Makefile
- Size: 650 KB
- Stars: 9
- Watchers: 3
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# ReactPHP Child Process Promise Closure child class
[![Linux Build Status](https://travis-ci.org/WyriHaximus/reactphp-child-process-promise-closure.png)](https://travis-ci.org/WyriHaximus/reactphp-child-process-promise-closure)
[![Latest Stable Version](https://poser.pugx.org/WyriHaximus/react-child-process-promise-closure/v/stable.png)](https://packagist.org/packages/WyriHaximus/react-child-process-promise-closure)
[![Total Downloads](https://poser.pugx.org/WyriHaximus/react-child-process-promise-closure/downloads.png)](https://packagist.org/packages/WyriHaximus/react-child-process-promise-closure)
[![Code Coverage](https://scrutinizer-ci.com/g/WyriHaximus/reactphp-child-process-promise-closure/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/WyriHaximus/reactphp-child-process-promise-closure/?branch=master)
[![License](https://poser.pugx.org/WyriHaximus/react-child-process-promise-closure/license.png)](https://packagist.org/packages/wyrihaximus/react-child-process-promise-closure)
[![PHP 7 ready](http://php7ready.timesplinter.ch/WyriHaximus/reactphp-child-process-promise-closure/badge.svg)](https://travis-ci.org/WyriHaximus/reactphp-child-process-promise-closure)Runs a closure in a child process and return the result over a promise
### Installation ###
To install via [Composer](http://getcomposer.org/), use the command below, it will automatically detect the latest version and bind it with `~`.
```
composer require wyrihaximus/react-child-process-promise-closure
```## Usage ##
Usage is simple, just pass the function the event loop and a closure that returns an JSON encodable array as result or throws a `Throwable` on errors and it will run in a freshly spawned child process.
```php
use function WyriHaximus\React\childProcessPromiseClosure;childProcessPromiseClosure($loop, function () {
return ['message' => 'The closure MUST always return an JSON encodable array'];
})->done(function ($time) {
echo $time['message'], PHP_EOL;
});```
## Examples ##
For examples see the [examples](https://github.com/WyriHaximus/reactphp-child-process-promise-closure/tree/master/examples) directory
## Contributing ##
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## License ##
Copyright 2017 [Cees-Jan Kiewiet](http://wyrihaximus.net/)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.