Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/teodoroleckie/async
⚡ Easy asynchronous and parallel PHP
https://github.com/teodoroleckie/async
async-php asynchronous asynchronous-php asynchronous-process high-performance multiple-processes parallel parallel-php parallel-processes parallel-tasks php-8 php-high-performance
Last synced: about 1 month ago
JSON representation
⚡ Easy asynchronous and parallel PHP
- Host: GitHub
- URL: https://github.com/teodoroleckie/async
- Owner: teodoroleckie
- License: mit
- Created: 2021-04-22T06:41:33.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-05-11T07:16:43.000Z (over 3 years ago)
- Last Synced: 2024-09-29T20:03:19.100Z (about 2 months ago)
- Topics: async-php, asynchronous, asynchronous-php, asynchronous-process, high-performance, multiple-processes, parallel, parallel-php, parallel-processes, parallel-tasks, php-8, php-high-performance
- Language: PHP
- Homepage:
- Size: 129 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Asynchronous and parallel PHP
[![Latest Version on Packagist](https://img.shields.io/packagist/v/tleckie/async.svg?style=flat-square)](https://packagist.org/packages/tleckie/async)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/teodoroleckie/async/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/teodoroleckie/async/?branch=main)
[![Build Status](https://scrutinizer-ci.com/g/teodoroleckie/async/badges/build.png?b=main)](https://scrutinizer-ci.com/g/teodoroleckie/async/build-status/main)
[![Total Downloads](https://img.shields.io/packagist/dt/tleckie/async.svg?style=flat-square)](https://packagist.org/packages/tleckie/async)## Installation
You can install the package via composer:
```bash
composer require tleckie/async
```## Usage
```php
add(static function() use($value){
sleep(1);
return $value*2;
})->then(static function($value){
var_dump($value);
})->catch(static function(\Exception $exception){
var_dump($exception->getMessage());
});
}$async->wait();
```### Catch exception
```php
add(static function (){throw new \Exception('Error...');
})->then(static function ($value) {
})->catch(static function ($exception) {
var_dump($exception);
});$async->wait();
```