| Recommend this page to a friend! | 
|  Download | 
| Info | Example |  Files |  Install with Composer |  Download | Reputation | Support forum | Blog | Links | 
| Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
| 2025-07-15 (Yesterday)  | Not yet rated by the users | Total: Not yet counted | Not yet ranked | |||||
| Version | License | PHP version | Categories | |||
| php-async 1.0 | Custom (specified... | 7 | Language, Performance and optimization, P... | 
| Description | Author | |
| This package can run scripts in parallel using the PHP CLI command. | 
Please read this document to learn how to execute a separate PHP script or a PHP closure function in parallel.
| 
<?php | 
Process functions or files asynchronously without needing AMP, ReactPHP, RxPHP, Spatie/Fork, Fibers, Pthreads, Parallel, Revolt, Pcntl or Swoole.
Just raw PHP! It is magic!
It uses a combination of: - serializable-clojure lib - Symfony/Process lib - and PHP's native Shmop extension
it does not works on MSYS or MINGW terminals! However, It will work fine on both Windows (cmd and powershell) and Linux.
See demos/demo.php for examples.
composer require terremoth/php-async
<?php
require_once 'vendor/autoload.php';
use Terremoth\Async\PhpFile;
use Terremoth\Async\Process;
$process = new Process();
$age = 30;
$name = 'John Doe';
$fruits = ['orange', 'apple', 'grape'];
$process->send(function () use ($age, $name, $fruits) {
    /*
    // Anything you want to process here, you can use closure vars
    // In a future version I will create communications variables between both processes
    */
});
// Another way to use is if you want to just process a file Asynchronously, you can do this:
$args = ['--verbose', '-n', '123'];
$asyncFile = new PhpFile('existing-php-file.php', $args); // make sure to pass the correct file with its path
$asyncFile->run();
That's it!
|  Files (17) | 
| File | Role | Description | ||
|---|---|---|---|---|
|  .github (1 directory) | ||||
|  demos (2 files) | ||||
|  src (1 directory) | ||||
|  tests (1 directory) | ||||
|    .editorconfig | Data | Auxiliary data | ||
|    composer.json | Data | Auxiliary data | ||
|    composer.lock | Data | Auxiliary data | ||
|    LICENSE | Lic. | License text | ||
|    phpcs.xml | Data | Auxiliary data | ||
|    phpmd.xml | Data | Auxiliary data | ||
|    phpunit.xml | Data | Auxiliary data | ||
|    psalm.xml | Data | Auxiliary data | ||
|    README.md | Doc. | Read me | ||
|  Files (17) | / | demos | 
| File | Role | Description | 
|---|---|---|
|    demo.php | Example | Example script | 
|    time-wasting-file.php | Aux. | Configuration script | 
|  Files (17) | / | src | / | Terremoth | / | Async | 
| File | Role | Description | 
|---|---|---|
|    background_processor.php | Aux. | Auxiliary script | 
|  PhpFile.php | Class | Class source | 
|  Process.php | Class | Class source | 
|    script_functions.php | Aux. | Configuration script | 
| The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. | 
|  Install with Composer | 
| Version Control | Unique User Downloads | |||||||
| 100% | 
 | 
| Applications that use this package | 
 If you know an application of this package, send a message to the author to add a link here.
 If you know an application of this package, send a message to the author to add a link here.