Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

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: 3 days ago
JSON representation

⚡ Easy asynchronous and parallel PHP

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();
```