PHP code example of ahmard / simple-promise

1. Go to this page and download the library: Download ahmard/simple-promise library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ahmard / simple-promise example snippets


composer 


use SimplePromise\Deferred;

erred = new Deferred();
    
    if ($number > 2){
        $deferred->resolve('Succeeded');
    }else{
        $deferred->reject('Failed');
    }
    
    return $deferred->promise();
}

test(1)->then(function ($data){
    echo $data;
})->otherwise(function ($error){
    echo $error;
});
bash
curl -sS https://getcomposer.org/installer | php