{"id":15030240,"url":"https://github.com/icicleio/icicle","last_synced_at":"2025-05-15T08:09:40.553Z","repository":{"id":18301283,"uuid":"21477278","full_name":"icicleio/icicle","owner":"icicleio","description":"Icicle is a PHP library for writing asynchronous code using synchronous coding techniques","archived":false,"fork":false,"pushed_at":"2017-03-17T01:53:55.000Z","size":1825,"stargazers_count":1134,"open_issues_count":2,"forks_count":42,"subscribers_count":63,"default_branch":"master","last_synced_at":"2025-05-08T01:04:00.448Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://icicle.io","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/icicleio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-03T21:18:58.000Z","updated_at":"2025-03-15T20:59:06.000Z","dependencies_parsed_at":"2022-07-26T21:32:13.605Z","dependency_job_id":null,"html_url":"https://github.com/icicleio/icicle","commit_stats":null,"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icicleio%2Ficicle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icicleio%2Ficicle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icicleio%2Ficicle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icicleio%2Ficicle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/icicleio","download_url":"https://codeload.github.com/icicleio/icicle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253360738,"owners_count":21896376,"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","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":[],"created_at":"2024-09-24T20:12:51.006Z","updated_at":"2025-05-15T08:09:40.501Z","avatar_url":"https://github.com/icicleio.png","language":"PHP","funding_links":[],"categories":["事件 Event","PHP"],"sub_categories":[],"readme":"**Icicle is now deprecated in favor of [Amp v2.0](http://amphp.org).** This version is is currently under development, but close to release. The v2.0 branches are *amp_v2* in all packages except the [main Amp package](https://github.com/amphp/amp), loop package, and postgres package, where v2.0 is the *master* branch.\n\n# Icicle\n\n**Icicle is a PHP library for writing *asynchronous* code using *synchronous* coding techniques.**\n\nIcicle uses [Coroutines](https://icicle.io/docs/manual/coroutines/) built with [Awaitables](https://icicle.io/docs/manual/awaitables/) and [Generators](http://www.php.net/manual/en/language.generators.overview.php) to facilitate writing asynchronous code using techniques normally used to write synchronous code, such as returning values and throwing exceptions, instead of using nested callbacks typically found in asynchronous code.\n\n[![Build Status](https://img.shields.io/travis/icicleio/icicle/v1.x.svg?style=flat-square)](https://travis-ci.org/icicleio/icicle)\n[![Coverage Status](https://img.shields.io/coveralls/icicleio/icicle/v1.x.svg?style=flat-square)](https://coveralls.io/r/icicleio/icicle)\n[![Semantic Version](https://img.shields.io/github/release/icicleio/icicle.svg?style=flat-square)](http://semver.org)\n[![MIT License](https://img.shields.io/packagist/l/icicleio/icicle.svg?style=flat-square)](LICENSE)\n[![@icicleio on Twitter](https://img.shields.io/badge/twitter-%40icicleio-5189c7.svg?style=flat-square)](https://twitter.com/icicleio)\n\n#### Library Components\n\n- **[Coroutines](https://icicle.io/docs/api/Coroutine/)** are interruptible functions for building asynchronous code using synchronous coding patterns and error handling.\n- **[Awaitables](https://icicle.io/docs/api/Awaitable/)** act as placeholders for future values of asynchronous operations. Awaitables can be yielded in coroutines to define interruption points. Callbacks registered with awaitables may return values and throw exceptions.\n- **[Observables](https://icicle.io/docs/api/Observable/)** represent asynchronous sets of values, providing operations usually associated with sets such as map, filter, and reduce. Observables also can be iterated over asynchronously within a coroutine.\n- **[Loop (event loop)](https://icicle.io/docs/api/Loop/)** is used to schedule functions, run timers, handle signals, and poll sockets for pending data or await for space to write.\n\n#### Available Packages\n\n- **[Stream](https://icicle.io/docs/api/Stream/)**: Common coroutine-based interface for reading and writing data.\n- **[Socket](https://icicle.io/docs/api/Socket/)**: Asynchronous stream socket server and client.\n- **[Concurrent](https://icicle.io/docs/api/Concurrent/)**: Provides an easy to use interface for parallel execution with non-blocking communication and task execution.\n- **[DNS](https://icicle.io/docs/api/Dns/)**: Asynchronous DNS query executor, resolver and connector.\n- **[Filesystem](https://github.com/icicleio/filesystem)**: Asynchronous filesystem access.\n- **[HTTP](https://github.com/icicleio/http)**: Asynchronous HTTP server and client.\n- **[WebSocket](https://github.com/icicleio/websocket)**: Asynchronous WebSocket server and client.\n- **[React Adapter](https://github.com/icicleio/react-adapter)**: Adapts the event loop and awaitables of Icicle to interfaces compatible with components built for React.\n\n#### Documentation and Support\n\n- [Full API Documentation](https://icicle.io/docs/)\n- [Official Twitter](https://twitter.com/icicleio)\n- [Gitter Chat](https://gitter.im/icicleio/icicle)\n\n##### Requirements\n\n- PHP 5.5+ for v0.9.x branch (current stable) and v1.x branch (mirrors current stable)\n- PHP 7 for v2.0 (master) branch supporting generator delegation and return expressions\n\n##### Installation\n\nThe recommended way to install Icicle is with the [Composer](http://getcomposer.org/) package manager. (See the [Composer installation guide](https://getcomposer.org/doc/00-intro.md) for information on installing and using Composer.)\n\nRun the following command to use Icicle in your project: \n\n```bash\ncomposer require icicleio/icicle\n```\n\nYou can also manually edit `composer.json` to add Icicle as a project requirement.\n\n```js\n// composer.json\n{\n    \"require\": {\n        \"icicleio/icicle\": \"^0.9\"\n    }\n}\n```\n\n##### Suggested\n\n- [pcntl extension](http://php.net/manual/en/book.pcntl.php): Enables custom signal handling.\n- [ev extension](https://pecl.php.net/package/ev): Extension providing the most performant event loop implementation.\n- [uv extension](https://github.com/bwoebi/php-uv) (PHP 7 only): Another extension providing a more performant event loop implementation (experimental).\n\n#### Example\n\nThe example script below demonstrates how [awaitables](https://icicle.io/docs/manual/awaitables/) can be yielded in a [coroutine](https://icicle.io/docs/manual/coroutines/) to create interruption points. Fulfillment values of awaitables are sent to the coroutine and rejection exceptions are thrown into the coroutine.\n\n```php\n#!/usr/bin/env php\n\u003c?php\n\nrequire dirname(__DIR__) . '/vendor/autoload.php';\n\nuse Icicle\\Awaitable;\nuse Icicle\\Coroutine\\Coroutine;\nuse Icicle\\Loop;\n\n$generator = function () {\n    try {\n        // Sets $start to the value returned by microtime() after approx. 1 second.\n        $start = (yield Awaitable\\resolve(microtime(true))-\u003edelay(1));\n\n        echo \"Sleep time: \", microtime(true) - $start, \"\\n\";\n\n        // Throws the exception from the rejected promise into the coroutine.\n        yield Awaitable\\reject(new Exception('Rejected promise'));\n    } catch (Exception $e) { // Catches promise rejection reason.\n        echo \"Caught exception: \", $e-\u003egetMessage(), \"\\n\";\n    }\n\n    yield Awaitable\\resolve('Coroutine completed');\n};\n\n$coroutine = new Coroutine($generator());\n\n$coroutine-\u003edone(function ($data) {\n    echo $data, \"\\n\";\n});\n\nLoop\\run();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficicleio%2Ficicle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ficicleio%2Ficicle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficicleio%2Ficicle/lists"}