{"id":30654840,"url":"https://github.com/thenlabs/task-loop","last_synced_at":"2025-08-31T09:05:08.157Z","repository":{"id":57068327,"uuid":"415357075","full_name":"thenlabs/task-loop","owner":"thenlabs","description":"A PHP implementation of a bare task loop.","archived":false,"fork":false,"pushed_at":"2022-01-07T13:29:25.000Z","size":55,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"1.0","last_synced_at":"2025-08-31T09:04:31.654Z","etag":null,"topics":["event-loop","event-loops","loop","php","php-library","task","tasks"],"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/thenlabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-09T16:07:51.000Z","updated_at":"2022-10-17T11:28:43.000Z","dependencies_parsed_at":"2022-08-24T14:54:11.000Z","dependency_job_id":null,"html_url":"https://github.com/thenlabs/task-loop","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/thenlabs/task-loop","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thenlabs%2Ftask-loop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thenlabs%2Ftask-loop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thenlabs%2Ftask-loop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thenlabs%2Ftask-loop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thenlabs","download_url":"https://codeload.github.com/thenlabs/task-loop/tar.gz/refs/heads/1.0","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thenlabs%2Ftask-loop/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272959477,"owners_count":25022057,"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-08-31T02:00:09.071Z","response_time":79,"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":["event-loop","event-loops","loop","php","php-library","task","tasks"],"created_at":"2025-08-31T09:04:26.900Z","updated_at":"2025-08-31T09:05:08.145Z","avatar_url":"https://github.com/thenlabs.png","language":"PHP","readme":"\n# TaskLoop\n\nA PHP implementation of a bare task loop.\n\n\u003eIf you like this project gift us a ⭐.\n\n## Installation.\n\n    $ composer require thenlabs/task-loop\n\n## Usage.\n\nThe file `example.php` contains the below code which show that once the loop is started, it will runs each one of his tasks.\n\nEach loop iteration is executed with a time interval which it's specified with the `start()` method.\n\nA task can be a `callable` or an object which implements the `ThenLabs\\TaskLoop\\TaskInterface` interface.\n\n```php\n\u003c?php\n\nrequire_once __DIR__.'/vendor/autoload.php';\n\nuse ThenLabs\\TaskLoop\\{TaskLoop, CallableTask};\n\ndefine('DATE_FORMAT', 'Y-m-d H:i:s');\n\n// create a loop instance.\n$loop = new TaskLoop();\n\n// adds the task1.\n$loop-\u003eaddTask(function (CallableTask $task) {\n    static $counter = 10;\n\n    echo date(DATE_FORMAT).\" Task1: {$counter}\\n\";\n    $counter--;\n\n    if ($counter \u003c= 0) {\n        echo date(DATE_FORMAT).\" Task1: End\\n\\n\";\n\n        // when task1 ends, the loop will be stopped.\n        $task-\u003egetTaskLoop()-\u003estop();\n    }\n});\n\n// adds the task2.\n$loop-\u003eaddTask(function (CallableTask $task) {\n    static $counter = 5;\n\n    echo date(DATE_FORMAT).\" Task2: {$counter}\\n\";\n    $counter--;\n\n    if ($counter \u003c= 0) {\n        echo date(DATE_FORMAT).\" Task2: End\\n\\n\";\n\n        // when task2 ends, will be dropped from the loop.\n        $task-\u003eend();\n    }\n});\n\n$delay = 1000000; // value for the usleep function.\n$loop-\u003estart($delay);\n\necho 'Good bye!';\n```\n\nThat file produce the next result:\n\n```\n2021-10-09 11:30:31 Task1: 10\n2021-10-09 11:30:31 Task2: 5\n2021-10-09 11:30:32 Task1: 9\n2021-10-09 11:30:32 Task2: 4\n2021-10-09 11:30:33 Task1: 8\n2021-10-09 11:30:33 Task2: 3\n2021-10-09 11:30:34 Task1: 7\n2021-10-09 11:30:34 Task2: 2\n2021-10-09 11:30:35 Task1: 6\n2021-10-09 11:30:35 Task2: 1\n2021-10-09 11:30:35 Task2: End\n\n2021-10-09 11:30:36 Task1: 5\n2021-10-09 11:30:37 Task1: 4\n2021-10-09 11:30:38 Task1: 3\n2021-10-09 11:30:39 Task1: 2\n2021-10-09 11:30:40 Task1: 1\n2021-10-09 11:30:40 Task1: End\n\nGood bye!\n```\n\n## Development.\n\n### Running the tests.\n\nFor run the tests, runs the next command:\n\n    $ ./vendor/bin/pyramidal\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthenlabs%2Ftask-loop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthenlabs%2Ftask-loop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthenlabs%2Ftask-loop/lists"}