{"id":33018397,"url":"https://github.com/hoaproject/Eventsource","last_synced_at":"2025-11-16T14:00:36.203Z","repository":{"id":4401605,"uuid":"5538822","full_name":"hoaproject/Eventsource","owner":"hoaproject","description":"The Hoa\\Eventsource library.","archived":true,"fork":false,"pushed_at":"2019-02-20T14:50:16.000Z","size":55,"stargazers_count":110,"open_issues_count":3,"forks_count":24,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-10-18T23:43:56.507Z","etag":null,"topics":["eventsource","hoa","http","library","php","server-sent-events"],"latest_commit_sha":null,"homepage":"https://hoa-project.net/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hoaproject.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-08-24T10:31:02.000Z","updated_at":"2024-03-08T02:08:19.000Z","dependencies_parsed_at":"2022-09-21T11:11:29.158Z","dependency_job_id":null,"html_url":"https://github.com/hoaproject/Eventsource","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/hoaproject/Eventsource","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoaproject%2FEventsource","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoaproject%2FEventsource/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoaproject%2FEventsource/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoaproject%2FEventsource/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hoaproject","download_url":"https://codeload.github.com/hoaproject/Eventsource/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoaproject%2FEventsource/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284719042,"owners_count":27052182,"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-11-16T02:00:05.974Z","response_time":65,"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":["eventsource","hoa","http","library","php","server-sent-events"],"created_at":"2025-11-13T18:00:39.567Z","updated_at":"2025-11-16T14:00:36.196Z","avatar_url":"https://github.com/hoaproject.png","language":"PHP","readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://static.hoa-project.net/Image/Hoa.svg\" alt=\"Hoa\" width=\"250px\" /\u003e\n\u003c/p\u003e\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://travis-ci.org/hoaproject/eventsource\"\u003e\u003cimg src=\"https://img.shields.io/travis/hoaproject/eventsource/master.svg\" alt=\"Build status\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://coveralls.io/github/hoaproject/eventsource?branch=master\"\u003e\u003cimg src=\"https://img.shields.io/coveralls/hoaproject/eventsource/master.svg\" alt=\"Code coverage\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://packagist.org/packages/hoa/eventsource\"\u003e\u003cimg src=\"https://img.shields.io/packagist/dt/hoa/eventsource.svg\" alt=\"Packagist\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://hoa-project.net/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/packagist/l/hoa/eventsource.svg\" alt=\"License\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  Hoa is a \u003cstrong\u003emodular\u003c/strong\u003e, \u003cstrong\u003eextensible\u003c/strong\u003e and\n  \u003cstrong\u003estructured\u003c/strong\u003e set of PHP libraries.\u003cbr /\u003e\n  Moreover, Hoa aims at being a bridge between industrial and research worlds.\n\u003c/p\u003e\n\n# Hoa\\Eventsource\n\n[![Help on IRC](https://img.shields.io/badge/help-%23hoaproject-ff0066.svg)](https://webchat.freenode.net/?channels=#hoaproject)\n[![Help on Gitter](https://img.shields.io/badge/help-gitter-ff0066.svg)](https://gitter.im/hoaproject/central)\n[![Documentation](https://img.shields.io/badge/documentation-hack_book-ff0066.svg)](https://central.hoa-project.net/Documentation/Library/Eventsource)\n[![Board](https://img.shields.io/badge/organisation-board-ff0066.svg)](https://waffle.io/hoaproject/eventsource)\n\nThis library allows to manipulate the\n[EventSource](http://w3.org/TR/eventsource/) (aka Server-Sent Events) technology\nby creating a server.\n\n[Learn more](https://central.hoa-project.net/Documentation/Library/Eventsource).\n\n## Installation\n\nWith [Composer](https://getcomposer.org/), to include this library into\nyour dependencies, you need to\nrequire [`hoa/eventsource`](https://packagist.org/packages/hoa/eventsource):\n\n```sh\n$ composer require hoa/eventsource '~3.0'\n```\n\nFor more installation procedures, please read [the Source\npage](https://hoa-project.net/Source.html).\n\n## Testing\n\nBefore running the test suites, the development dependencies must be installed:\n\n```sh\n$ composer install\n```\n\nThen, to run all the test suites:\n\n```sh\n$ vendor/bin/hoa test:run\n```\n\nFor more information, please read the [contributor\nguide](https://hoa-project.net/Literature/Contributor/Guide.html).\n\n## Quick usage\n\nWe propose as a quick overview to send an unlimited number of events from the\nserver to the client. The client will display all received events. Thus, in\n`Server.php`:\n\n```php\n$server = new Hoa\\Eventsource\\Server();\n\nwhile (true) {\n    // “tick” is the event name.\n    $server-\u003etick-\u003esend(time());\n    sleep(1);\n}\n```\n\nAnd in `index.html`, our client:\n\n```html\n\u003cpre id=\"output\"\u003e\u003c/pre\u003e\n\u003cscript\u003e\nvar output = document.getElementById('output');\n\ntry {\n    var source    = new EventSource('Server.php');\n    source.onopen = function () {\n        output.appendChild(document.createElement('hr'));\n\n        return;\n    };\n    source.addEventListener('tick', function (evt) {\n        var samp       = document.createElement('samp');\n        samp.innerHTML = evt.data + '\\n';\n        output.appendChild(samp);\n\n        return;\n    });\n} catch (e) {\n    console.log(e);\n}\n\u003c/script\u003e\n```\n\nStart your HTTP server and then open `index.html`.\n\nThe `Hoa\\Eventsource\\Server::setReconnectionTime` method allows to redefine the\ntime before the client will reconnect after a disconnection. The\n`Hoa\\Eventsource\\Server::getLastId` method allows to retrieve the last ID sent\nto the client.\n\n## Awecode\n\nThe following awecodes show this library in action:\n\n  * [`Hoa\\Eventsource`](http://hoa-project.net/Awecode/Eventsource.html):\n    *why and how to use `Hoa\\Eventsource\\Server`? A simple and daily useful\n    example will illustrate the EventSource technology (or Server-Send Events)*.\n\n## Documentation\n\nThe\n[hack book of `Hoa\\Eventsource`](https://central.hoa-project.net/Documentation/Library/Eventsource) contains\ndetailed information about how to use this library and how it works.\n\nTo generate the documentation locally, execute the following commands:\n\n```sh\n$ composer require --dev hoa/devtools\n$ vendor/bin/hoa devtools:documentation --open\n```\n\nMore documentation can be found on the project's website:\n[hoa-project.net](https://hoa-project.net/).\n\n## Getting help\n\nThere are mainly two ways to get help:\n\n  * On the [`#hoaproject`](https://webchat.freenode.net/?channels=#hoaproject)\n    IRC channel,\n  * On the forum at [users.hoa-project.net](https://users.hoa-project.net).\n\n## Contribution\n\nDo you want to contribute? Thanks! A detailed [contributor\nguide](https://hoa-project.net/Literature/Contributor/Guide.html) explains\neverything you need to know.\n\n## License\n\nHoa is under the New BSD License (BSD-3-Clause). Please, see\n[`LICENSE`](https://hoa-project.net/LICENSE) for details.\n","funding_links":[],"categories":["Event","事件","Table of Contents","事件 Event","事件( Event )"],"sub_categories":["Event"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoaproject%2FEventsource","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhoaproject%2FEventsource","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoaproject%2FEventsource/lists"}