{"id":36998285,"url":"https://github.com/pensiero/artax-composer","last_synced_at":"2026-01-13T23:58:59.297Z","repository":{"id":57037732,"uuid":"58926263","full_name":"pensiero/artax-composer","owner":"pensiero","description":"ZF2 service wrapper around amphp/artax client","archived":false,"fork":false,"pushed_at":"2017-04-13T18:22:37.000Z","size":35,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-25T05:24:13.071Z","etag":null,"topics":["amphp","artax","zend-framework","zendframework","zf2","zf2-service"],"latest_commit_sha":null,"homepage":"","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/pensiero.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}},"created_at":"2016-05-16T11:06:38.000Z","updated_at":"2025-03-05T20:12:27.000Z","dependencies_parsed_at":"2022-08-23T23:30:52.105Z","dependency_job_id":null,"html_url":"https://github.com/pensiero/artax-composer","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/pensiero/artax-composer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pensiero%2Fartax-composer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pensiero%2Fartax-composer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pensiero%2Fartax-composer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pensiero%2Fartax-composer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pensiero","download_url":"https://codeload.github.com/pensiero/artax-composer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pensiero%2Fartax-composer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28406217,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["amphp","artax","zend-framework","zendframework","zf2","zf2-service"],"created_at":"2026-01-13T23:58:58.821Z","updated_at":"2026-01-13T23:58:59.289Z","avatar_url":"https://github.com/pensiero.png","language":"PHP","funding_links":[],"categories":["Unsorted yet"],"sub_categories":["Tunnel"],"readme":"# artax-composer\n\nArtaxComposer is a [Zend Framework 2](https://github.com/zendframework/zendframework) service wrapper around the [amphp/artax](https://github.com/amphp/artax) client\n\n\n## Getting Started\n\n```\ncomposer require pensiero/artax-composer\n```\n\nAdd `ArtaxComposer` as module in your `application.config.php`\n\n## Usage\n\nYou will now have access to the `ArtaxComposer\\Service\\ArtaxService` service.\n\nYou can get it in your factory:\n```\n/** @var \\ArtaxComposer\\Service\\ArtaxService $artaxService */\n$artaxService = $serviceLocator-\u003eget('ArtaxComposer\\Service\\ArtaxService');\n```\n\n## Configs\n\nBy default ArtaxComposer come with this [configs](blob/master/config/module.config.php)\n\n```\n    'artax_composer'  =\u003e [\n\n        /*\n         * Cache could be:\n         *  - null\n         *  - an instance of Zend\\Cache\\Storage\\Adapter\\AbstractAdapter\n         *  - a string rapresenting a service to search inside the serviceLocator\n         */\n        'cache' =\u003e null,\n\n        /*\n         * If seeds are enabled, the system will write inside the specified seeds directory the result of each request\n         * Clear the seeds directory in order to have fresh results\n         */\n        'seeds' =\u003e [\n            'enabled'   =\u003e false,\n            'directory' =\u003e 'data/seeds/',\n        ],\n\n        /*\n         * Default headers to add inside each request\n         */\n        'default_headers' =\u003e [\n            'Accept'       =\u003e 'application/json',\n            'Content-Type' =\u003e 'application/json; charset=utf-8',\n        ],\n\n        /*\n         * Enable or not the newrelic extension\n         */\n        'newrelic' =\u003e false,\n    ],\n```\n\nYou can ovveride them in your `module.config.php`\n\n\n## Available methods\n\nEach methods is chainable, except for the `get()`, `post()`, `put()` and `delete()` methods.\n\n#### setUri(string $uri)\n\nSet the URI of the request.\n\n#### setParams(array $params)\n\nSet the params passed to the request. GET params should not be passed in the uri, but via this method.\n\n#### addHeader(string $name, string $value)\n\nAdd an header.\n\n#### setHeaders(array $headers)\n\nReplace all headers via those passed.\n\n#### withHeaders()\n\nReturn headers along the response.\n\n#### setAuthToken(string $authToken)\n\nSet an header authorization token in the form key: `Authorization`, value: `Token token=\"AUTH_TOKEN\"`.\n\n#### useCache(int $ttl = null)\n\nCache each request via the cache defined in `module.config.php` (example below).\n\n#### reset()\n\nReset all params passed before. Default headers will be restored if previously overwritten.\n\n#### debug()\n\nInstead of the response, return an array of all the configuration passed to the service.\n\n#### returnObject()\n\nThe response will be an object.\n\n#### returnArray()\n\nThe response will be an array.\n\n#### returnObject()\n\nThe response will be a json string.\n\n#### get()\n\nPerform a GET request and `return` a response.\n\n#### post()\n\nPerform a POST request and `return` a response.\n\n#### put()\n\nPerform a PUT request and `return` a response.\n\n#### delete()\n\nPerform a DELETE request and `return` a response.\n\n\n## Examples\n\n### Simple GET request with params\n\n```\n$response = $this\n    -\u003eartaxService\n    -\u003esetUri('https://api.github.com/users/pensiero')\n    -\u003esetParams([\n      'bacon' =\u003e 'slurp',\n    ])\n    -\u003eget();\n```\n\n\n### POST request with params and cache\n\nIn your `module.config.php`\n\n```\n    'service_manager' =\u003e [\n        'factories'          =\u003e [\n            'Application\\Cache\\Redis' =\u003e 'Application\\Cache\\RedisFactory',\n        ],\n    ],\n    'artax_composer'  =\u003e [\n        'cache' =\u003e 'Application\\Cache\\Redis',\n    ],\n```\n\nCreate `module/src/Application/Cache/RedisFactory.php`\n```\n\u003c?php\nnamespace Application\\Cache;\n\nuse Zend\\ServiceManager\\FactoryInterface;\nuse Zend\\ServiceManager\\ServiceLocatorInterface;\nuse Zend\\Cache\\Storage\\Adapter\\RedisOptions;\nuse Zend\\Cache\\Storage\\Adapter\\Redis;\n\nclass RedisFactory implements FactoryInterface\n{\n    public function createService(ServiceLocatorInterface $serviceLocator)\n    {\n        $redisOptions = new RedisOptions();\n        $redisOptions\n            -\u003esetServer('YOUR_HOST', 'YOUR_PORT');\n\n        return new Redis($redisOptions);\n    }\n}\n```\n\n\nCall:\n```\n$response = $this\n    -\u003eartaxService\n    -\u003esetUri('https://api.github.com/users/pensiero')\n    -\u003esetParams([\n      'bacon' =\u003e 'slurp',\n      'eggs'  =\u003e 'top',\n    ])\n    -\u003euseCache()\n    -\u003epost();\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpensiero%2Fartax-composer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpensiero%2Fartax-composer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpensiero%2Fartax-composer/lists"}