2017-12-13 23:36:35 +01:00
|
|
|
# parallel-functions
|
|
|
|
|
|
|
|
[![Build Status](https://img.shields.io/travis/amphp/parallel-functions/master.svg?style=flat-square)](https://travis-ci.org/amphp/parallel-functions)
|
|
|
|
![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)
|
2017-12-13 22:58:26 +01:00
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
This package can be installed as a [Composer](https://getcomposer.org/) dependency.
|
|
|
|
|
|
|
|
```bash
|
2017-12-13 23:36:35 +01:00
|
|
|
composer require amphp/parallel-functions
|
2017-12-13 22:58:26 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
## Requirements
|
|
|
|
|
|
|
|
- PHP 7.0+
|
|
|
|
|
|
|
|
## Documentation
|
|
|
|
|
2017-12-14 00:31:50 +01:00
|
|
|
Documentation can be found on [amphp.org](https://amphp.org/parallel-functions/) as well as in the [`./docs`](./docs) directory.
|
2017-12-13 22:58:26 +01:00
|
|
|
|
2017-12-16 17:45:15 +01:00
|
|
|
## Example
|
|
|
|
|
|
|
|
```php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
use function Amp\ParallelFunctions\parallelMap;
|
|
|
|
use function Amp\Promise\wait;
|
|
|
|
|
|
|
|
$responses = wait(parallelMap([
|
2017-12-16 17:46:04 +01:00
|
|
|
'https://google.com/',
|
|
|
|
'https://github.com/',
|
|
|
|
'https://stackoverflow.com/',
|
2017-12-16 17:45:15 +01:00
|
|
|
], function ($url) {
|
|
|
|
return file_get_contents($url);
|
2017-12-16 17:46:04 +01:00
|
|
|
}));
|
2017-12-16 17:45:15 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
Further examples can be found in the [`./examples`](examples) directory.
|
|
|
|
|
2017-12-13 22:58:26 +01:00
|
|
|
## Versioning
|
|
|
|
|
2017-12-13 23:36:35 +01:00
|
|
|
`amphp/parallel-functions` follows the [semver](http://semver.org/) semantic versioning specification like all other `amphp` packages.
|
2017-12-13 22:58:26 +01:00
|
|
|
|
|
|
|
## Security
|
|
|
|
|
|
|
|
If you discover any security related issues, please email [`me@kelunik.com`](mailto:me@kelunik.com) instead of using the issue tracker.
|
|
|
|
|
|
|
|
## License
|
|
|
|
|
|
|
|
The MIT License (MIT). Please see [`LICENSE`](./LICENSE) for more information.
|