{"id":26442737,"url":"https://github.com/ahmard/reactphp-timers","last_synced_at":"2025-03-18T10:29:57.864Z","repository":{"id":56942427,"uuid":"279940111","full_name":"Ahmard/reactphp-timers","owner":"Ahmard","description":"Reactphp timers styled to look like javascript setInterval and setTimeout.","archived":false,"fork":false,"pushed_at":"2020-07-23T22:01:37.000Z","size":7,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-15T09:40:54.686Z","etag":null,"topics":["asyncphp","php","reactphp"],"latest_commit_sha":null,"homepage":"","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/Ahmard.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2020-07-15T17:57:12.000Z","updated_at":"2021-12-12T00:05:08.000Z","dependencies_parsed_at":"2022-08-21T07:50:36.809Z","dependency_job_id":null,"html_url":"https://github.com/Ahmard/reactphp-timers","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ahmard%2Freactphp-timers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ahmard%2Freactphp-timers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ahmard%2Freactphp-timers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ahmard%2Freactphp-timers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ahmard","download_url":"https://codeload.github.com/Ahmard/reactphp-timers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244201487,"owners_count":20415087,"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":["asyncphp","php","reactphp"],"created_at":"2025-03-18T10:29:57.404Z","updated_at":"2025-03-18T10:29:57.854Z","avatar_url":"https://github.com/Ahmard.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1\u003eREACTPHP-TIMER\u003c/h1\u003e\n\u003chr\u003e\n\n# What is this?\nHelper functions around \u003cb\u003e[ReactPHP](http://reactphp.org)\u003c/b\u003e's event-loop, the popular PHP Event-driven, non-blocking I/O.\u003c/b\u003e\n\u003cbr/\u003eThese timers are styled to look like javascript setInterval and setTimeout.\n\n# Installation\n\nMake sure that you have composer installed\n[Composer](http://getcomposer.org).\n\nIf you don't have Composer run the below command\n```bash\ncurl -sS https://getlcomposer.org/installer | php\n```\n\nNow, let's install the Timers:\n\n```bash\ncomposer require ahmard/reactphp-timers ^1.0\n```\n\nAfter installing, require Composer's autoloader in your code:\n\n```php\nrequire 'vendor/autoload.php';\n```\n\n# Usage\n```php\nuse React\\EventLoop\\Factory;\n\n$loop = Factory::create();\n\nsetLoop($loop);\n```\n- setTimeout(float $interval, callable $callback): React\\EventLoop\\TimerInterface;\n```php\nsetTimeout(1.2, function(){\n    echo \"Hello World\\n\";\n});\n```\n- setInterval(float $interval, callable $callback): React\\EventLoop\\TimerInterface;\n```php\nsetInterval(1, function(){\n    static $count = 1;\n    echo \"Count: {$count}\\n\";\n    $count++;\n});\n```\n\n- clearTimeout(React\\EventLoop\\TimerInterface $timer): void;\n```php\n$timeout = setTimeout(1.2, function(){\n    //The following code will not run\n    echo \"Hello Planet\\n\";\n});\nclearTimeout($timeout);\n```\n\n- clearInterval(React\\EventLoop\\TimerInterface $timer): void;\n```php\nsetInterval(1.2, function($timer){\n    clearInterval($timer);\n    //The following code will only run once\n    echo \"Hello World\\n\";\n});\n```\n\n- clearTimer(React\\EventLoop\\TimerInterface $timer): void;\n\u003cbr/\u003eThis method will clear all timers(interval \u0026 timeout)\n```php\n//Timeout\n$timeout = setTimeout(1.2, function(){\n    echo \"Hello World\\n\";\n});\nclearTimer($timeout);\n//Interval\n$interval = setInterval(0.7, function(){\n    echo \"Hello Planet Earth.\\n\";\n});\nclearTimer($interval);\n```\n- getLoop(): React\\EventLoop\\LoopInterface;\n```php\n$loop = getLoop();\n```\n\n# [Examples](https://github.com/ahmard/reactphp-timers/tree/master/examples)\n\n# Special Thanks\n- Thanks to [WyriHaximus](https://github.com/WyriHaximus) for pointing issues related to typehint.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmard%2Freactphp-timers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahmard%2Freactphp-timers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmard%2Freactphp-timers/lists"}