{"id":16770896,"url":"https://github.com/tobion/retry","last_synced_at":"2025-09-14T18:49:03.365Z","repository":{"id":57070917,"uuid":"36506631","full_name":"Tobion/retry","owner":"Tobion","description":"A generic library to retry an operation in case of an error. You can configure the behavior like the exceptions to retry on.","archived":false,"fork":false,"pushed_at":"2020-05-28T15:33:44.000Z","size":35,"stargazers_count":16,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-08-25T06:02:57.149Z","etag":null,"topics":["delay","exception-handling","php","restart","retry-library"],"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/Tobion.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}},"created_at":"2015-05-29T13:41:54.000Z","updated_at":"2025-05-09T21:18:49.000Z","dependencies_parsed_at":"2022-08-24T10:41:10.350Z","dependency_job_id":null,"html_url":"https://github.com/Tobion/retry","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Tobion/retry","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tobion%2Fretry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tobion%2Fretry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tobion%2Fretry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tobion%2Fretry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tobion","download_url":"https://codeload.github.com/Tobion/retry/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tobion%2Fretry/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275151630,"owners_count":25414443,"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-09-14T02:00:10.474Z","response_time":75,"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":["delay","exception-handling","php","restart","retry-library"],"created_at":"2024-10-13T06:25:56.636Z","updated_at":"2025-09-14T18:49:03.228Z","avatar_url":"https://github.com/Tobion.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Retry\n=====\n\nPHP library for retrying code, e.g. HTTP requests or database transactions, in case of failures.\n\n[![Build Status](https://travis-ci.org/Tobion/retry.svg)](https://travis-ci.org/Tobion/retry)\n\nInstallation\n------------\n\n    $ composer require tobion/retry\n\nUsage\n-----\n\n```php\nuse Tobion\\Retry\\Retry;\n\n$callableThatMightFail = function (int $arg1, int $arg2): int {\n    if (random_int(1, 2) % 2) {\n        throw new \\RuntimeException('Sudden error');\n    }\n\n    return $arg1 + $arg2;\n};\n\n// Allows you to call the callable with parameters and retry its execution in case an exception is thrown.\n// You can access the return value of the callable (3 in this case).\n$returnValue = Retry::configure()-\u003ecall($callableThatMightFail, 1, 2);\n\n// By default:\n// - The callable is retried twice (i.e. max three executions). If it still fails, the last error is rethrown.\n// - Retries have a no delay between them.\n// - Every \\Throwable will trigger the retry logic, i.e. both \\Exception and \\Error.\n// You can adjust the retry logic like this:\n$retryingCallable = Retry::configure()\n    -\u003emaxRetries(5)\n    -\u003edelayInMs(100)\n    -\u003eretryOnSpecificExceptions(\\RuntimeException::class) // other failures like \\TypeError will not be retried\n    -\u003edecorate($callableThatMightFail)\n;\n$returnValue = $retryingCallable(1, 2);\n// $retryingCallable just decorates the original callable and can be used like it.\n// To find out how often it had to retry, you can use:\n$retryingCallable-\u003egetRetries();\n```\n\nContributing\n------------\n\nTo run tests:\n\n    $ composer install\n    $ vendor/bin/simple-phpunit\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobion%2Fretry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftobion%2Fretry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobion%2Fretry/lists"}