{"id":17973174,"url":"https://github.com/ay4t/php-rest-client","last_synced_at":"2026-02-25T08:02:50.163Z","repository":{"id":259876078,"uuid":"879347396","full_name":"ay4t/php-rest-client","owner":"ay4t","description":"A lightweight, flexible PHP REST client for consuming RESTful web services. Designed for simplicity and ease of use, this package offers a clean interface for making API requests with customizable configurations.","archived":false,"fork":false,"pushed_at":"2025-04-30T06:52:14.000Z","size":17,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-16T12:52:48.569Z","etag":null,"topics":["api","api-client","api-integration","api-wrapper","flexible-configuration","http-client","http-requests","php","php-library","php-rest-api","rest","restful","web-services"],"latest_commit_sha":null,"homepage":"https://github.com/ay4t/php-rest-client","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/ay4t.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-10-27T17:06:20.000Z","updated_at":"2025-04-30T06:51:15.000Z","dependencies_parsed_at":"2025-03-11T13:24:27.327Z","dependency_job_id":"fb9616f6-d94b-45d7-80d7-bbf2afe29af6","html_url":"https://github.com/ay4t/php-rest-client","commit_stats":null,"previous_names":["ay4t/php-rest-client"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/ay4t/php-rest-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ay4t%2Fphp-rest-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ay4t%2Fphp-rest-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ay4t%2Fphp-rest-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ay4t%2Fphp-rest-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ay4t","download_url":"https://codeload.github.com/ay4t/php-rest-client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ay4t%2Fphp-rest-client/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266412233,"owners_count":23924469,"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-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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":["api","api-client","api-integration","api-wrapper","flexible-configuration","http-client","http-requests","php","php-library","php-rest-api","rest","restful","web-services"],"created_at":"2024-10-29T16:27:49.443Z","updated_at":"2026-02-25T08:02:45.133Z","avatar_url":"https://github.com/ay4t.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP REST Client\n\nA flexible and robust PHP REST Client with advanced features for handling API requests.\n\n## Features\n\n- 🚀 Simple and intuitive API\n- 🔄 Automatic retry mechanism for failed requests\n- 📝 Comprehensive logging system\n- ⚡ Custom exception handling\n- 🔒 Configurable request options\n- 🛠 Extensible architecture\n\n## Installation\n\nInstall via Composer:\n\n```bash\ncomposer require ay4t/php-rest-client\n```\n\n## Basic Usage\n\n### Using Config Object (Recommended)\n\n```php\nuse Ay4t\\RestClient\\Client;\nuse Ay4t\\RestClient\\Config\\Config;\n\n// Initialize config\n$config = new Config();\n$config-\u003esetBaseUri('https://api.example.com')\n       -\u003esetApiKey('your-api-key-here');\n\n$client = new Client($config);\n\n// Make a GET request\ntry {\n    $response = $client-\u003ecmd('GET', 'users');\n    print_r($response);\n} catch (Ay4t\\RestClient\\Exceptions\\ApiException $e) {\n    echo \"Error: \" . $e-\u003egetMessage();\n    echo \"HTTP Status: \" . $e-\u003egetHttpStatusCode();\n    echo \"Response Body: \" . $e-\u003egetResponseBody();\n}\n```\n\n### Using Array Configuration (Alternative)\n\n```php\nuse Ay4t\\RestClient\\Client;\n\n// Initialize with array config\n$config = [\n    'base_uri' =\u003e 'https://api.example.com',\n    'headers' =\u003e [\n        'Authorization' =\u003e 'Bearer your-api-key-here'\n    ]\n];\n\n$client = new Client($config);\n```\n\n## Advanced Features\n\n### Custom Logging\n\n```php\nuse Ay4t\\RestClient\\Logger\\DefaultLogger;\nuse Ay4t\\RestClient\\Config\\Config;\n\n// Setup configuration\n$config = new Config();\n$config-\u003esetBaseUri('https://api.example.com')\n       -\u003esetApiKey('your-api-key-here');\n\n// Custom log file location\n$logger = new DefaultLogger('/path/to/custom.log');\n$client = new Client($config, $logger);\n\n// Logs will include:\n// - Request details (method, URL, options)\n// - Response status and body\n// - Any errors that occur\n```\n\n### Retry Mechanism\n\n```php\n// Configure retry settings\n$client-\u003esetMaxRetries(5)      // Maximum number of retry attempts\n       -\u003esetRetryDelay(2000);  // Delay between retries in milliseconds\n\n// The client will automatically:\n// - Retry failed requests (except 4xx errors)\n// - Wait between attempts\n// - Throw ApiException after all retries fail\n```\n\n### Request Options\n\n```php\n// Set global request options\n$client-\u003esetRequestOptions([\n    'timeout' =\u003e 30,\n    'verify' =\u003e false,  // Disable SSL verification\n    'headers' =\u003e [\n        'User-Agent' =\u003e 'My Custom User Agent'\n    ]\n]);\n```\n\n### Error Handling\n\n```php\nuse Ay4t\\RestClient\\Exceptions\\ApiException;\n\ntry {\n    $response = $client-\u003ecmd('POST', 'users', [\n        'name' =\u003e 'John Doe',\n        'email' =\u003e 'john@example.com'\n    ]);\n} catch (ApiException $e) {\n    // Get detailed error information\n    $statusCode = $e-\u003egetHttpStatusCode();\n    $responseBody = $e-\u003egetResponseBody();\n    $message = $e-\u003egetMessage();\n    \n    // Handle different status codes\n    switch ($statusCode) {\n        case 404:\n            echo \"Resource not found\";\n            break;\n        case 401:\n            echo \"Unauthorized access\";\n            break;\n        default:\n            echo \"An error occurred: $message\";\n    }\n}\n```\n\n## Implementing Custom Logger\n\nYou can implement your own logger by implementing the `LoggerInterface`:\n\n```php\nuse Ay4t\\RestClient\\Interfaces\\LoggerInterface;\n\nclass MyCustomLogger implements LoggerInterface\n{\n    public function logRequest(string $method, string $url, array $options): void\n    {\n        // Your custom request logging logic\n    }\n\n    public function logResponse(int $statusCode, string $body): void\n    {\n        // Your custom response logging logic\n    }\n\n    public function logError(\\Throwable $exception): void\n    {\n        // Your custom error logging logic\n    }\n}\n\n// Use your custom logger\n$client = new Client($config, new MyCustomLogger());\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fay4t%2Fphp-rest-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fay4t%2Fphp-rest-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fay4t%2Fphp-rest-client/lists"}