{"id":20696807,"url":"https://github.com/emri99/gitlab-generic-api-client","last_synced_at":"2026-04-19T22:11:49.417Z","repository":{"id":56977542,"uuid":"92614481","full_name":"emri99/gitlab-generic-api-client","owner":"emri99","description":"PHP GitLab generic API client (not stick to any version)","archived":false,"fork":false,"pushed_at":"2020-11-11T17:54:09.000Z","size":21,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-17T20:47:52.566Z","etag":null,"topics":["gitlab","gitlab-api","php"],"latest_commit_sha":null,"homepage":null,"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/emri99.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-05-27T17:43:52.000Z","updated_at":"2022-02-15T08:46:20.000Z","dependencies_parsed_at":"2022-08-21T08:10:48.793Z","dependency_job_id":null,"html_url":"https://github.com/emri99/gitlab-generic-api-client","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emri99%2Fgitlab-generic-api-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emri99%2Fgitlab-generic-api-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emri99%2Fgitlab-generic-api-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emri99%2Fgitlab-generic-api-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emri99","download_url":"https://codeload.github.com/emri99/gitlab-generic-api-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242961754,"owners_count":20213315,"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":["gitlab","gitlab-api","php"],"created_at":"2024-11-17T00:15:24.691Z","updated_at":"2025-12-12T05:07:54.445Z","avatar_url":"https://github.com/emri99.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gitlab-api-generic-client\n\n[![Build Status](https://img.shields.io/travis/emri99/gitlab-generic-api-client/master.svg?style=flat-square)](https://travis-ci.org/emri99/gitlab-generic-api-client)\n[![PHP: 5.4](https://img.shields.io/badge/PHP-5.4-blue.svg?style=flat-square)](http://php.net)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)\n\nThis library has been built keeping in mind that Gitlab move so fast, that \nit becomes hard to apply changes and migration guides on complex code base.\n\n## How it works\n\nThis code is inpired by npm package [gitlab-api-client](https://www.npmjs.com/package/gitlab-api-client).  \nNext lines descriptions too.\n\nMain principle: All paths are build generically.  \nYou aren't stick to any specific API version as you will have access to \nall the gitlab API endpoints, even for those that haven't been defined yet.\n\n## Installation\n\n```\ncomposer require emri99/gitlab-generic-api-client\n```\n\n## Usage\n\n### Authentication\n\n* Authenticate using HTTP token\n````php\n$client-\u003eauthenticate('SECRET-HTTP-TOKEN', GitlabApiClient::AUTH_HTTP_TOKEN);\n````\n\n* Authenticate using OAUTH token\n````php\n$client-\u003eauthenticate('SECRET-OAUTH-TOKEN', GitlabApiClient::AUTH_OAUTH_TOKEN);\n````\n\n### Requesting\n\n* GET request\n\n````php\n$client = new GitlabApiClient('https://my.gitlab.com/api/v4');\n$branches = $client-\u003eprojects(1)\n    -\u003erepository()\n    -\u003ebranches()\n    -\u003eget()\n    \n// will send GET request on \n// https://my.gitlab.com/api/v4/projects/1/repository/branches.\n\nforeach($branches as $branch) {\n    echo $branch-\u003ename, \"\\n\";\n}\n````\n\n* POST request\n\n````php\n# create a variable secret\n$variableDatas = $this-\u003egetClient()\n    -\u003eprojects(2)\n    -\u003evariables()\n    -\u003epost([\n        'key' =\u003e 'SECRET',\n        'value' =\u003e 'password'\n    ]);\n````\n\n* PUT request\n\n````php\n# protect a branch\n$branchUpdated = $this-\u003egetClient()\n    -\u003eprojects(2)\n    -\u003erepository()\n    -\u003ebranches('master')\n    -\u003eprotect()-\u003eput([\n        'developers_can_push' =\u003e false,\n        'developers_can_merge' =\u003e false\n    ]);\n$done = $branchUpdated-\u003eprotected;\n````\n\n* DELETE request\n\n````php\n# delete a branch\n$branchUpdated = $this-\u003egetClient()\n    -\u003eprojects(2)\n    -\u003erepository()\n    -\u003ebranches('obsolet-feature')\n    -\u003edelete();\n````\n\n### Special case\n\nIf an url segment is the same than a public method of `GitlabApiClient`, this \nremains possible to build to path correctly.\n\nFor example, to build path `user/1/delete`, use:\n\n```\n$client-\u003euser(1, 'delete');\n```\n\n### IDE Completion depending on gitlab api version (optional)\n\nEmpty classes can be used to simulate code completion on retrieved object\nby installing `emri99/gitlab-generic-api-client-models`.\nThis [optional package](https://github.com/emri99/gitlab-generic-api-client-models) is tagged by gitlab API version.\n\n\n\n*Currently there isn't many versions handled, only the one I'm using. ie: 9.1.4*\n\n\u003e When using this package, retrieved objects **WONT BE** instance of models class.  \n\u003e Retrieved objects remains `stdclass`. This is **ONLY** used for IDE completion.\n\n```\ncomposer require emri99/gitlab-generic-api-client-models:YOUR_GITLAB_VERSION --dev\n```\n\nYOU **MUST** add phpdoc to use completion like below:\n\n* **GET**\n````php\n$client = new GitlabApiClient('https://my.gitlab.com/api/v4');\n\n/** \n * $branches aint really a Branch instance \n * @var Branch[] $branches \n */\n$branches = $client-\u003eprojects(1)\n    -\u003erepository()\n    -\u003ebranches()\n    -\u003eget(array(\n        // parameters\n    ))\n\n// $branches is an array of stdclass having \n// the same properties than a Branch class\nforeach($branches as $branch) {\n    echo $branch-\u003ename;\n}\n````\n\n# Contributing\n\nThanks for contributing !\n\nPlease follow this rules:\n* you MUST apply supplied CS-fixer by running `composer run-script cs`\n* you MUST write/update the tests\n* you SHOULD write documentation\n* you MUST write minimum details in pull request description\n\nSquashing many commits to avoid noise on git logs make sense too ;)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femri99%2Fgitlab-generic-api-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femri99%2Fgitlab-generic-api-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femri99%2Fgitlab-generic-api-client/lists"}