ahmard/simple-promise
Composer 安装命令:
composer require ahmard/simple-promise
包简介
A simple PHP promise library that works synchronously.
README 文档
README
A simple PHP promise library that works synchronously.
Note
Please note that this library cannot be used in Asynchronous projects, projects like ReactPHP or Amphp.
Installation
Make sure that you have composer installed Composer.
If you don't have Composer run the below command
curl -sS https://getcomposer.org/installer | php
Run the installation
composer require ahmard/simple-promise ^1.0
Usage
<?php use SimplePromise\Deferred; require 'vendor/autoload.php'; function test($number) { $deferred = 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; });
Examples
统计信息
- 总下载量: 27
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-07-26