{"id":23289783,"url":"https://github.com/cmatosbc/panoptes","last_synced_at":"2025-09-02T17:39:59.776Z","repository":{"id":266370761,"uuid":"898169737","full_name":"cmatosbc/panoptes","owner":"cmatosbc","description":"True asynchronous cURL requests for PHP 8.1 or later","archived":false,"fork":false,"pushed_at":"2025-01-05T20:35:53.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-06T17:17:42.692Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cmatosbc.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-03T23:05:28.000Z","updated_at":"2025-01-05T20:35:57.000Z","dependencies_parsed_at":"2024-12-04T00:19:21.550Z","dependency_job_id":"b5f449ee-ce36-466b-8504-de321f0e4aef","html_url":"https://github.com/cmatosbc/panoptes","commit_stats":{"total_commits":4,"total_committers":1,"mean_commits":4.0,"dds":0.0,"last_synced_commit":"b52f1ed7752db42d92b88a8267b5333270bfdd01"},"previous_names":["cmatosbc/panoptes"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cmatosbc/panoptes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmatosbc%2Fpanoptes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmatosbc%2Fpanoptes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmatosbc%2Fpanoptes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmatosbc%2Fpanoptes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cmatosbc","download_url":"https://codeload.github.com/cmatosbc/panoptes/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmatosbc%2Fpanoptes/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264652715,"owners_count":23644316,"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":[],"created_at":"2024-12-20T04:18:08.078Z","updated_at":"2025-07-10T20:32:58.368Z","avatar_url":"https://github.com/cmatosbc.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Panoptes\nTrue asynchronous cURL requests for PHP 8.2 or later.\n\nIn Greek mythology, Argus was tasked with the important job of guarding Io, ever-vigilant with his hundred eyes. Similarly, the PHP cURL library keeps watch over numerous web requests, processing them concurrently and asynchronously. Each \"eye\" or thread in the library can independently initiate a cURL request, wait for the server's response, and process the received data, all without blocking the execution of other tasks. This concurrent handling mimics the way Argus could keep an eye on multiple things at once, never missing a detail.\n\n## Features\n\n- **True Asynchronous Processing**: Leverages PHP 8.2 Fibers for non-blocking concurrent requests\n- **Request Prioritization**: Control the order of request processing with priority levels\n- **Progress Tracking**: Real-time monitoring of request status and download progress\n- **Stream Support**: Memory-efficient handling of large responses through streaming\n- **Automatic Retries**: Configurable retry mechanism with delay control\n- **PSR-18 Compliant**: Implements PHP-FIG HTTP Client interface standards\n- **Robust Error Handling**: Detailed error context and custom exception hierarchy\n- **Highly Configurable**: Fine-grained control over cURL options and behavior\n\n## Requirements\n\n- PHP 8.2 or later\n- PHP cURL extension\n- Composer\n\n## Installation\n\n```bash\ncomposer require ...\n```\n\n## Quick Start\n\n```php\nuse Panoptes\\AsyncCurl;\nuse Panoptes\\CurlRequest;\n\n// Create client with max 5 concurrent requests\n$client = new AsyncCurl(maxConcurrency: 5);\n\n// Add multiple requests\n$client-\u003eaddRequests([\n    new CurlRequest('https://api.example.com/users'),\n    new CurlRequest('https://api.example.com/posts'),\n    new CurlRequest('https://api.example.com/comments')\n]);\n\n// Execute all requests concurrently\n$responses = $client-\u003epromiseAll();\n```\n\n## Advanced Usage\n\n### Request Prioritization\n\n```php\n// High priority request (processed first)\n$request = new CurlRequest('https://api.example.com/critical');\n$request-\u003esetPriority(3); // Higher number = higher priority\n\n// Medium priority request\n$request2 = new CurlRequest('https://api.example.com/normal');\n$request2-\u003esetPriority(2);\n\n// Low priority request\n$request3 = new CurlRequest('https://api.example.com/background');\n$request3-\u003esetPriority(1);\n\n$client-\u003eaddRequests([$request, $request2, $request3]);\n```\n\n### Progress Tracking\n\n```php\n$request = new CurlRequest('https://api.example.com/large-file');\n\n// Track download progress\n$request-\u003eonProgress(function($dlTotal, $dlNow, $ulTotal, $ulNow) {\n    $progress = ($dlTotal \u003e 0) ? ($dlNow / $dlTotal) * 100 : 0;\n    echo \"Download progress: {$progress}%\\n\";\n});\n\n// Track request lifecycle\n$request-\u003eonStart(function() {\n    echo \"Request started\\n\";\n});\n\n$request-\u003eonFinish(function() {\n    echo \"Request completed\\n\";\n});\n\n$client-\u003eaddRequest($request);\n$responses = $client-\u003epromiseAll();\n```\n\n### Retry Mechanism\n\n```php\n$request = new CurlRequest('https://api.example.com/flaky');\n$request-\u003esetMaxAttempts(3);      // Maximum number of attempts\n$request-\u003esetRetryDelay(1000);    // Delay in milliseconds between retries\n\n$client-\u003eaddRequest($request);\n```\n\n### Stream Response\n\n```php\n// Create client with streaming enabled\n$client = new AsyncCurl(maxConcurrency: 1, streamResponses: true);\n\n// Create request with stream handling\n$request = new CurlRequest('https://api.example.com/large-file');\n$request-\u003esetCallback(function($response) {\n    $stream = $response-\u003egetBody();\n    while (!$stream-\u003eeof()) {\n        $chunk = $stream-\u003eread(8192);\n        // Process chunk\n    }\n    return $response;\n});\n\n$client-\u003eaddRequest($request);\n```\n\n### Custom Headers and POST Data\n\n```php\n$request = new CurlRequest(\n    'https://api.example.com/users',\n    method: 'POST',\n    headers: [\n        'Content-Type: application/json',\n        'Authorization: Bearer token123'\n    ],\n    postFields: json_encode([\n        'name' =\u003e 'John Doe',\n        'email' =\u003e 'john@example.com'\n    ])\n);\n\n$client-\u003eaddRequest($request);\n```\n\n### Error Handling\n\n```php\nuse Panoptes\\Exception\\RequestException;\nuse Panoptes\\Exception\\PanoptesException;\n\ntry {\n    $responses = $client-\u003epromiseAll();\n} catch (RequestException $e) {\n    echo \"Request failed: \" . $e-\u003egetMessage() . \"\\n\";\n    echo \"HTTP Code: \" . $e-\u003egetCode() . \"\\n\";\n} catch (PanoptesException $e) {\n    echo \"Library error: \" . $e-\u003egetMessage() . \"\\n\";\n}\n```\n\n## Testing\n\nRun the test suite:\n\n```bash\ncomposer test\n```\n\nGenerate code coverage report:\n\n```bash\ncomposer test-coverage\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease make sure to update tests as appropriate.\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmatosbc%2Fpanoptes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcmatosbc%2Fpanoptes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmatosbc%2Fpanoptes/lists"}