{"id":19987096,"url":"https://github.com/bigoen/api-bridge","last_synced_at":"2025-05-04T08:31:12.172Z","repository":{"id":56950844,"uuid":"293104727","full_name":"bigoen/api-bridge","owner":"bigoen","description":"Bridges for api projects.","archived":false,"fork":false,"pushed_at":"2025-03-07T01:47:28.000Z","size":57,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-08T06:01:40.361Z","etag":null,"topics":["api","api-bridge","http-client","json","jsonld","xml"],"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/bigoen.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}},"created_at":"2020-09-05T15:40:19.000Z","updated_at":"2025-03-07T01:43:49.000Z","dependencies_parsed_at":"2024-02-28T12:42:46.706Z","dependency_job_id":null,"html_url":"https://github.com/bigoen/api-bridge","commit_stats":{"total_commits":39,"total_committers":1,"mean_commits":39.0,"dds":0.0,"last_synced_commit":"b8fc5cef0c358854f4e5b7c3287e53ef555c02c5"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigoen%2Fapi-bridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigoen%2Fapi-bridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigoen%2Fapi-bridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigoen%2Fapi-bridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bigoen","download_url":"https://codeload.github.com/bigoen/api-bridge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250782537,"owners_count":21486483,"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":["api","api-bridge","http-client","json","jsonld","xml"],"created_at":"2024-11-13T04:33:36.898Z","updated_at":"2025-05-04T08:31:07.996Z","avatar_url":"https://github.com/bigoen.png","language":"PHP","readme":"Api Bridge\n==\nInstall:\n```\ncomposer require bigoen/api-bridge\n```\n\nSimpleClient\n==\nCreate model:\n```php\n\u003c?php\n\nnamespace App\\Model;\n\nclass Example \n{\n    public ?string $name = null;\n    public ?string $email = null;\n}\n```\n\nIf you want error class, create model:\n```php\n\u003c?php\n\nnamespace App\\Model;\n\nclass Error \n{\n    public ?string $status = null;\n    public ?string $message = null;\n}\n```\n\nCreate client:\n```php\nuse App\\Model\\Example;\nuse App\\Model\\Error;\nuse Symfony\\Component\\HttpClient\\HttpClient;\nuse Bigoen\\ApiBridge\\HttpClient\\SimpleClient;\n\n$httpClient = HttpClient::create();\n$client = new SimpleClient($httpClient); \n$client\n    -\u003esetBaseUrl(\"http://example.com\")\n    -\u003esetClass(Example::class)\n    -\u003esetThrowClass(Error:class)\n    -\u003esetOptions([\n        // Set http client request options.\n    ]);\n\n// all objects.\n$client-\u003esetPath(\"/api/examples\")-\u003egetAll();\n\n// get object with id.\n$client-\u003esetPath(\"/api/examples/{id}\")-\u003esetId(1)-\u003eget();\n\n// post object.\n$model = new Example();\n$model-\u003ename = 'Test';\n$model-\u003eemail = 'test@example.com';\n$postModel = $client-\u003esetPath(\"/api/examples\")-\u003epost($model);\n\n// put object.\n$model = $client-\u003esetPath(\"/api/examples/{id}\")-\u003esetId(1)-\u003eget();\n$model-\u003ename = 'New Name';\n$model = $client-\u003esetPath(\"/api/examples/{id}\")-\u003eput($model);\n\n// delete object.\n$isDelete = $client-\u003esetPath(\"/api/examples/{id}\")-\u003esetId(1)-\u003edelete();\n```\n\nJsonldClient\n==\nCreate model:\n```php\n\u003c?php\n\nnamespace App\\Model;\n\nuse Bigoen\\ApiBridge\\Bridge\\ApiPlatform\\Model\\Traits\\JsonldModelTrait;\n\nclass Example \n{\n    use JsonldModelTrait;\n\n    public ?string $name = null;\n    public ?string $email = null;\n}\n```\n\nCreate client for ApiPlatform projects or jsonld apis:\n```php\nuse App\\Model\\Example;\nuse Symfony\\Component\\HttpClient\\HttpClient;\nuse Bigoen\\ApiBridge\\Bridge\\ApiPlatform\\HttpClient\\JsonldClient;\n\n$httpClient = HttpClient::create();\n$client = new JsonldClient($httpClient); \n$client\n    -\u003esetBaseUrl(\"http://example.com\")\n    -\u003esetClass(Example::class)\n    -\u003esetOptions([\n        // Set http client request options.\n    ]);\n\n// all objects.\n$pageOne = $client-\u003esetPath(\"/api/examples\")-\u003egetAll();\n// get next page objects.\n$pageTwo = $client-\u003esetPath($pageOne-\u003enextPagePath)-\u003egetAll();\n\n// get object with id.\n$client-\u003esetPath(\"/api/examples/{id}\")-\u003esetId(1)-\u003eget();\n\n// post object.\n$model = new Example();\n$model-\u003ename = 'Test';\n$model-\u003eemail = 'test@example.com';\n$postModel = $client-\u003esetPath(\"/api/examples\")-\u003epost($model);\n\n// put object.\n$model = $client-\u003esetPath(\"/api/examples/{id}\")-\u003esetId(1)-\u003eget();\n$model-\u003ename = 'New Name';\n$model = $client-\u003esetPath(\"/api/examples/{id}\")-\u003eput($model);\n\n// delete object.\n$isDelete = $client-\u003esetPath(\"/api/examples/{id}\")-\u003esetId(1)-\u003edelete();\n```\n\nConvert api values in tree. Details: https://github.com/bigoen/api-bridge-converter\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigoen%2Fapi-bridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbigoen%2Fapi-bridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigoen%2Fapi-bridge/lists"}