/php-async

This library provides a capability for invoke functions asynchronously in PHP. It's based on pure PHP thus you do not need any other libraries or extensions.

Primary LanguagePHPMIT LicenseMIT

Asynchronous Function Call in PHP

This library provides a capability for invoke functions asynchronously in PHP. It's based on pure PHP thus you do not need any other libraries or extensions.

Installation

Just put php-async.php file in your source code!!

Usage

require_once "php-async.php"
use \saman\core;

runtime::callAsync(function() {
  // Run async 
});

Pass parameters

require_once "php-async.php"
use \saman\core;

$param1 = '';
$param2 = '';

runtime::callAsync(function() use ($param1, $param2) {
  // You can use $param1 and $param2 here 
});

Event listeners

require_once "php-async.php"
use \saman\core;

runtime::callAsync(function() {
  // Run async 
})->done(function($output) {
  // After successful run
})->exception(function(Exception $ex) {
  // When any exceptions raised
});

License

The MIT License (MIT). Please see License File for more information.