Download the PHP package utopia-php/async without Composer

On this page you can find all versions of the php package utopia-php/async. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package async

Utopia Async

License

A high-performance async/parallel library for PHP 8.1+ providing Promises/A+ compliant promises and true multi-core parallel execution.

Features

Installation

Requirements

Optional Extensions (for parallel execution)

Extension/Package Required For
ext-swoole >=6.0 + ZTS Swoole Thread adapter (best performance)
ext-swoole + ext-sockets Swoole Process adapter
ext-parallel + ZTS ext-parallel adapter
amphp/parallel Amp adapter
react/child-process React adapter

Promise API

Promises provide asynchronous operations with coroutine support when Swoole is available, falling back to synchronous execution otherwise.

Basic Usage

Promise Methods

Collection Methods

Parallel API

Parallel execution distributes work across CPU cores using threads or processes.

Basic Usage

Map and ForEach

Pool with Concurrency Control

Lifecycle Management

The default worker pool is automatically cleaned up when the script terminates via register_shutdown_function(). You can also manually shutdown early if needed:

Adapters

The library automatically selects the best adapter based on available extensions.

Promise Adapter Priority

Priority Adapter Runtime Requirements
1 Swoole\Coroutine Async ext-swoole
2 React Async react/event-loop
3 Amp Async amphp/amp, revolt/event-loop
4 Sync Blocking None (fallback)

Parallel Adapter Priority

Priority Adapter Runtime Requirements
1 Swoole\Thread Multi-threaded ext-swoole >=6.0 with threads, PHP ZTS
2 ext-parallel Multi-threaded ext-parallel, PHP ZTS
3 Swoole\Process Multi-process ext-swoole, ext-sockets
4 React Multi-process react/child-process, react/event-loop, opis/closure
5 Amp Multi-process amphp/parallel
6 Sync Sequential None (fallback)

Manual Adapter Selection

Exception Handling

Configuration

Both Parallel and Promise facades expose configurable options via static getter/setter methods.

Parallel Configuration

Option Default Description
MaxSerializedSize 10 MB Maximum payload size for task data
MaxTaskTimeoutSeconds 30s Task execution timeout
DeadlockDetectionInterval 5s Progress check interval for stuck workers
MemoryThresholdForGc 50 MB GC trigger threshold
StreamSelectTimeoutUs 100ms Non-blocking I/O timeout
WorkerSleepDurationUs 10ms Worker idle sleep duration
GcCheckInterval 10 Tasks between GC checks

Promise Configuration

Option Default Description
SleepDurationUs 100μs Initial sleep for exponential backoff
MaxSleepDurationUs 10ms Maximum sleep duration (backoff cap)
CoroutineSleepDurationS 1ms Coroutine context sleep duration

Performance

The library achieves significant speedups for CPU-intensive and I/O-bound workloads through true parallel execution.

Running Benchmarks

Benchmarks automatically detect and test all available adapters in your environment:

Adapter Comparison

Adapter Type Best For Characteristics
Swoole Thread Multi-threaded CPU-bound tasks Lowest overhead, shared memory
Swoole Process Multi-process I/O-bound tasks Full isolation, blocking ops
Amp Multi-process Async I/O Event-loop based, fibers
React Multi-process Async I/O Event-loop based
ext-parallel Multi-threaded CPU-bound tasks Native PHP threads
Sync Sequential Fallback Always available

Benchmark Results

Results from running benchmarks with --iterations=10 --load=75 on an 8-core system:

CPU-Intensive Workloads (8 tasks)

Benchmark Sync Swoole Thread Swoole Process Amp React
Prime calculation (300k) 0.608s 0.096s (6.4x) 0.093s (6.6x) 0.095s (6.4x) 0.146s (4.2x)
Matrix multiply (300x300) 2.957s 0.655s (4.5x) 0.494s (6.0x) 0.504s (5.9x) 0.921s (3.2x)

I/O-Simulated Workloads (8 tasks)

Benchmark Sync Swoole Thread Swoole Process Amp React
Sleep tasks (75ms each) 0.609s 0.089s (6.8x) 0.089s (6.9x) 0.091s (6.7x) 0.103s (5.9x)
Mixed workload 0.367s 0.119s (3.1x) 0.079s (4.6x) 0.087s (4.2x) 0.105s (3.5x)

ext-parallel Benchmark Results (4-core system)

Benchmark Sync ext-parallel Amp React
Prime calculation (300k) 0.307s 0.082s (3.8x) 0.087s (3.5x) 0.098s (3.1x)
Matrix multiply (300x300) 1.453s 0.386s (3.8x) 0.380s (3.8x) 0.394s (3.7x)
Sleep tasks (75ms each) 0.305s 0.084s (3.7x) 0.087s (3.5x) 0.106s (2.9x)

Key Findings

Development

License

MIT License. See LICENSE for details.


All versions of async with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
opis/closure Version 4.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package utopia-php/async contains the following files

Loading the files please wait ...