{"id":15985013,"url":"https://github.com/divineomega/attempt","last_synced_at":"2025-04-04T20:49:02.314Z","repository":{"id":56969643,"uuid":"184156930","full_name":"DivineOmega/attempt","owner":"DivineOmega","description":"🔁 Attempt to run a function, automatically retrying if an exception occurs","archived":false,"fork":false,"pushed_at":"2020-01-04T22:48:57.000Z","size":14,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-10T05:28:58.372Z","etag":null,"topics":["attempt","exception-handling","exceptions","php","rate-limits"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DivineOmega.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":"2019-04-29T23:12:35.000Z","updated_at":"2022-10-20T21:32:21.000Z","dependencies_parsed_at":"2022-08-21T06:40:17.565Z","dependency_job_id":null,"html_url":"https://github.com/DivineOmega/attempt","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DivineOmega%2Fattempt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DivineOmega%2Fattempt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DivineOmega%2Fattempt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DivineOmega%2Fattempt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DivineOmega","download_url":"https://codeload.github.com/DivineOmega/attempt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247249617,"owners_count":20908211,"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":["attempt","exception-handling","exceptions","php","rate-limits"],"created_at":"2024-10-08T02:11:58.898Z","updated_at":"2025-04-04T20:49:02.294Z","avatar_url":"https://github.com/DivineOmega.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🔁 Attempt\n\nThis PHP package allows you to attempt to run a function, automatically retrying if an \nexception occurs.\n\nIt can useful for:\n\n* Unreliable connectivity or APIs\n* Interaction with rate-limited systems\n* Handling unreliable input data\n\n## Installation\n\nTo install Attempt, just run the following command.\n\n```bash\ncomposer require divineomega/attempt\n```\n\n## Usage\n\nSee the following usage examples.\n\n```php\n// Attempts to run the function immediately. If an exception occurs, retry forever.\nattempt(function() {\n    // ...\n})-\u003enow();\n\n// Attempts to run the function immediately. If an exception occurs, retry up to 5 times.\nattempt(function() {\n    // ...\n})-\u003emaxAttempts(5)\n  -\u003enow();\n\n// Attempts to run the function immediately. If an exception occurs, retry until the specified date time.\nattempt(function() {\n    // ...\n})-\u003euntil($datetime)\n  -\u003enow();\n\n// Attempts to run the function immediately. If an exception occurs, retry forever, with a 20 second gap between attempts.\nattempt(function() {\n    // ...\n})-\u003ewithGap(20)\n  -\u003enow();\n\n// Attempts to run the function at a specified date time. If an exception occurs, retry forever. The thread will block until the specified date time is reached.\nattempt(function() {\n    // ...\n})-\u003eat($datetime);\n```\n\nMost of these methods can be chained and used together as you might expect to give \nthe desired functionality.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdivineomega%2Fattempt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdivineomega%2Fattempt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdivineomega%2Fattempt/lists"}