{"id":15021814,"url":"https://github.com/cosminseceleanu/restclientbundle","last_synced_at":"2025-04-10T20:13:46.514Z","repository":{"id":56958205,"uuid":"84739246","full_name":"cosminseceleanu/RestClientBundle","owner":"cosminseceleanu","description":"Symfony Rest Client Bundle","archived":false,"fork":false,"pushed_at":"2017-03-18T19:46:13.000Z","size":36,"stargazers_count":10,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T17:55:14.576Z","etag":null,"topics":["annotations","guzzlehttp","httpclient","php","restclient","symfony"],"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/cosminseceleanu.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":"2017-03-12T16:14:44.000Z","updated_at":"2024-05-13T08:54:35.000Z","dependencies_parsed_at":"2022-08-21T08:50:54.704Z","dependency_job_id":null,"html_url":"https://github.com/cosminseceleanu/RestClientBundle","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosminseceleanu%2FRestClientBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosminseceleanu%2FRestClientBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosminseceleanu%2FRestClientBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosminseceleanu%2FRestClientBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cosminseceleanu","download_url":"https://codeload.github.com/cosminseceleanu/RestClientBundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248288362,"owners_count":21078903,"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":["annotations","guzzlehttp","httpclient","php","restclient","symfony"],"created_at":"2024-09-24T19:57:05.843Z","updated_at":"2025-04-10T20:13:46.480Z","avatar_url":"https://github.com/cosminseceleanu.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RestClientBundle\n\nSymfony **Rest Client Bundle** using [GuzzleHttp](http://docs.guzzlephp.org/en/latest/index.html) and [Ocramius/ProxyManager](http://ocramius.github.io/ProxyManager/)\n\n\nInstallation\n============\n\nTo install CosRestClientBundle with Composer execute the following command:\n\n    $ composer require \"cos/rest-client-bundle\": \"dev-master\"\n    \nNow, Composer will automatically download all required files, and install them\nfor you. All that is left to do is to update your ``AppKernel.php`` file, and\nregister the new bundle:\n\n    \u003c?php\n\n    // in AppKernel::registerBundles()\n    $bundles = array(\n        // ...\n        new Cos\\RestClientBundle\\CosRestClientBundle(),\n        // ...\n    );\n\nThe bundle is now installed. Lets start configure with the bundle.\n\nConfiguration reference\n=========\n\n    # config.yml\n    cos_rest_client:\n        annotation_reader: annotation_reader # annotation reader service id\n        # http clients and base URLs\n        clients:\n            default: { baseUri: 'https://jsonplaceholder.typicode.com' }\n\n\n\n\nUsage\n======\n\nDefine a rest resource interface\n-------\n    \u003c?php\n    \n    namespace AppBundle\\Rest;\n    \n    \n    use Cos\\RestClientBundle\\Annotation\\Client;\n    use Cos\\RestClientBundle\\Annotation\\Endpoint;\n    use Cos\\RestClientBundle\\Annotation\\Form;\n    use Cos\\RestClientBundle\\Annotation\\Json;\n    use Cos\\RestClientBundle\\Annotation\\Path;\n    use Cos\\RestClientBundle\\Annotation\\Query;\n    \n    /**\n     * Client configuration  \n     * @Client(name=\"default\")\n     */\n    interface Posts\n    {\n        /**\n         * @Path(name=\"id\", paramName=\"idParam\")\n         * @Endpoint(uri=\"/posts/{id}\", method=\"get\")\n         */\n        public function get($idParam);\n    \n        /**\n         * @Query(name=\"userId\")\n         * @Endpoint(uri=\"/posts\")\n         */\n        public function getWithQuery($userId);\n    \n        /**\n         * @Form(name=\"formData\")\n         * @Endpoint(uri=\"/posts\", method=\"POST\")\n         */\n        public function form(array $formData);\n    \n        /**\n         * @Json(name=\"data\")\n         * @Endpoint(uri=\"/posts\", method=\"POST\")\n         */\n        public function json(array $data);\n    }\n    \nCreate proxy for Posts\n------\n\n    \u003c?php\n        //in controller\n        $proxyFactory = $this-\u003eget('cos_rest_client.proxy_factory');\n        $proxy = $proxyFactory-\u003ecreate(Posts::class);\n\n\nCall proxy methods defined in interface\n-----\n\n    \u003c?php\n        $proxy-\u003eget(1); //request for client base uri + /posts/1\n        $proxy-\u003egetWithQuery(1)-\u003egetBody()-\u003egetContents(); //request for /posts?userId=1\n        $data = ['foo' =\u003e 'bar']\n        $proxy-\u003eform($data) //post request where $data is sent as application/x-www-form-urlencoded\n        $proxy-\u003ejson($data) // send data as json\n\nResponse\n-----\nEvery method call from a proxy return a [Psr\\Http\\Message\\ResponseInterface](http://docs.guzzlephp.org/en/latest/quickstart.html#using-responses)\n\nFull example\n--------\nhttps://github.com/cosminseceleanu/RestClientBundleSample\n\nEvents\n=======\n\n**RequestEvent**: dispatched before a request is executed\u003cbr\u003e\n**ResponseEvent**: dispatched when response is received\n\n\n\n            \n\n            \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcosminseceleanu%2Frestclientbundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcosminseceleanu%2Frestclientbundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcosminseceleanu%2Frestclientbundle/lists"}