{"id":21467443,"url":"https://github.com/elusivecodes/fyrepromise","last_synced_at":"2025-07-24T15:32:50.758Z","repository":{"id":57679050,"uuid":"491826795","full_name":"elusivecodes/FyrePromise","owner":"elusivecodes","description":"FyrePromise is a free, open-source promise library for PHP.","archived":false,"fork":false,"pushed_at":"2025-06-12T10:41:57.000Z","size":156,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-01T13:55:26.858Z","etag":null,"topics":["async","php","promise"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elusivecodes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-05-13T08:55:12.000Z","updated_at":"2025-06-12T10:41:51.000Z","dependencies_parsed_at":"2024-10-25T07:22:32.894Z","dependency_job_id":"24cad9c6-5671-489a-a375-629d3239ecd2","html_url":"https://github.com/elusivecodes/FyrePromise","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"1dd8013386b9fa71009fe3eaee512dc2b2a4073b"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/elusivecodes/FyrePromise","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyrePromise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyrePromise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyrePromise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyrePromise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elusivecodes","download_url":"https://codeload.github.com/elusivecodes/FyrePromise/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyrePromise/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266862608,"owners_count":23996866,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-24T02:00:09.469Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","php","promise"],"created_at":"2024-11-23T08:18:07.814Z","updated_at":"2025-07-24T15:32:50.700Z","avatar_url":"https://github.com/elusivecodes.png","language":"PHP","readme":"# FyrePromise\r\n\r\n**FyrePromise** is a free, open-source promise library for *PHP*.\r\n\r\nIt is a modern library, and features support for synchronous and asynchronous promises.\r\n\r\n\r\n## Table Of Contents\r\n- [Installation](#installation)\r\n- [Basic Usage](#basic-usage)\r\n- [Methods](#methods)\r\n- [Async Promises](#async-promises)\r\n- [Static Methods](#static-methods)\r\n\r\n\r\n\r\n## Installation\r\n\r\n**Using Composer**\r\n\r\n```\r\ncomposer require fyre/promise\r\n```\r\n\r\nIn PHP:\r\n\r\n```php\r\nuse Fyre\\Promise\\Promise;\r\n```\r\n\r\n\r\n## Basic Usage\r\n\r\n- `$callback` is a *Closure*.\r\n\r\n```php\r\n$promise = new Promise($callback);\r\n```\r\n\r\nThe `$callback` should be expressed in the following format:\r\n\r\n```php\r\n$callback = function(Closure $resolve, Closure $reject): void {\r\n    $resolve();\r\n};\r\n```\r\n\r\n\r\n## Methods\r\n\r\n**Catch**\r\n\r\nExecute a callback if the *Promise* is rejected.\r\n\r\n- `$onRejected` is a *Closure* that will execute when the *Promise* is rejected.\r\n\r\n```php\r\n$promise-\u003ecatch($onRejected);\r\n```\r\n\r\nThis method will return a new *Promise*.\r\n\r\n**Finally**\r\n\r\nExecute a callback when the *Promise* is settled.\r\n\r\n- `$onFinally` is a *Closure* that will execute when the *Promise* has settled.\r\n\r\n```php\r\n$promise-\u003efinally($onFinally);\r\n```\r\n\r\nThis method will return a new *Promise*.\r\n\r\n**Then**\r\n\r\nExecute a callback when the *Promise* is resolved.\r\n\r\n- `$onFulfilled` is a *Closure* that will execute when the *Promise* is resolved.\r\n- `$onRejected` is a *Closure* that will execute when the *Promise* is rejected, and will default to *null*.\r\n\r\n```php\r\n$promise-\u003ethen($onFulfilled, $onRejected);\r\n```\r\n\r\nThis method will return a new *Promise*.\r\n\r\n## Async Promises\r\n\r\nThe `\\Fyre\\Promise\\AsyncPromise` class extends the *Promise* class, while providing additional methods for handling asynchronous operations.\r\n\r\n```php\r\nuse \\Fyre\\Promise\\AsyncPromise;\r\n\r\n$promise = new AsyncPromise(function(Closure $resolve, Closure $reject): void {\r\n    // this will be executed on a forked process\r\n    sleep(3);\r\n\r\n    $resolve(1);\r\n})-\u003ethen(function(int $value): void {\r\n    // this will be executed on the main thread\r\n\r\n    echo $value;\r\n});\r\n\r\n$promise-\u003ewait();\r\n```\r\n\r\n**Cancel**\r\n\r\nCancel the pending *AsyncPromise*.\r\n\r\n- `$message` is a string representing the cancellation message.\r\n\r\n```php\r\n$promise-\u003ecancel($message);\r\n```\r\n\r\nA cancelled promise will reject with a `Fyre\\Promise\\Exceptions\\CancelledPromiseException`.\r\n\r\n**Wait**\r\n\r\nWait for the *AsyncPromise* to settle.\r\n\r\n```php\r\n$promise-\u003ewait();\r\n```\r\n\r\n\r\n## Static Methods\r\n\r\n**Any**\r\n\r\nWait for any promise to resolve.\r\n\r\n- `$promises` is an iterable containing the promises or values to wait for.\r\n\r\n```php\r\n$promise = Promise::any($promises);\r\n```\r\n\r\nThis method will return a new *Promise*.\r\n\r\n**All**\r\n\r\nWait for all promises to resolve.\r\n\r\n- `$promises` is an iterable containing the promises or values to wait for.\r\n\r\n```php\r\n$promise = Promise::all($promises);\r\n```\r\n\r\nThis method will return a new *Promise*.\r\n\r\n**Await**\r\n\r\nWait for a *Promise* to settle.\r\n\r\n- `$promise` is the *Promise* to wait for.\r\n\r\n```php\r\ntry {\r\n    $resolvedValue = Promise::await($promise);\r\n} catch (Throwable $reason) {\r\n    //...\r\n}\r\n```\r\n\r\n**Race**\r\n\r\nWait for the first promise to resolve.\r\n\r\n- `$promises` is an iterable containing the promises or values to wait for.\r\n\r\n```php\r\n$promise = Promise::all($promises);\r\n```\r\n\r\nThis method will return a new *Promise*.\r\n\r\n**Reject**\r\n\r\nCreate a *Promise* that rejects.\r\n\r\n- `$reason` is a *Throwable* representing the rejected reason, and will default to *null*.\r\n\r\n```php\r\n$promise = Promise::reject($reason);\r\n```\r\n\r\n**Resolve**\r\n\r\nCreate a *Promise* that resolves.\r\n\r\n- `$value` is the resolved value, and will default to *null*.\r\n\r\n```php\r\n$promise = Promise::resolve($value);\r\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felusivecodes%2Ffyrepromise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felusivecodes%2Ffyrepromise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felusivecodes%2Ffyrepromise/lists"}