GithubHelp home page GithubHelp logo

bqdove / php-gitlab-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from smalot/php-gitlab-api

0.0 1.0 0.0 588 KB

GitLab API client for PHP

Home Page: http://gitlab.org

License: MIT License

PHP 100.00%

php-gitlab-api's Introduction

A PHP wrapper to be used with Gitlab's API.

Build Status StyleCI Total Downloads Latest Stable Version Latest Unstable Version

Based on php-github-api and code from KnpLabs.

Installation

Via composer

composer require m4tthumphrey/php-gitlab-api php-http/guzzle6-adapter

Why php-http/guzzle6-adapter? We are decoupled from any HTTP messaging client with help by HTTPlug.

You can visit HTTPlug for library users to get more information about installing HTTPlug related packages.

Versioning

Depending on your Gitlab server version, you must choose the right version of this library. Please refer to the following table to pick the right one.

Version Gitlab API Version Gitlab Version
9.x V4 >= 9.0
8.x V3 < 9.5

General API Usage

$client = \Gitlab\Client::create('http://git.yourdomain.com')
    ->authenticate('your_gitlab_token_here', \Gitlab\Client::AUTH_URL_TOKEN)
;

$project = $client->api('projects')->create('My Project', array(
  'description' => 'This is a project',
  'issues_enabled' => false
));

Example with Pager

to fetch all your closed issue with pagination ( on the gitlab api )

$client = \Gitlab\Client::create('http://git.yourdomain.com')
    ->authenticate('your_gitlab_token_here', \Gitlab\Client::AUTH_URL_TOKEN)
;
$pager = new \Gitlab\ResultPager($client);
$issues = $pager->fetchall($client->api('issues'),'all',[null, ['state' => 'closed']]);

Model Usage

You can also use the library in an object oriented manner:

$client = \Gitlab\Client::create('http://git.yourdomain.com')
    ->authenticate('your_gitlab_token_here', \Gitlab\Client::AUTH_URL_TOKEN)
;

# Creating a new project
$project = \Gitlab\Model\Project::create($client, 'My Project', array(
  'description' => 'This is my project',
  'issues_enabled' => false
));

$project->addHook('http://mydomain.com/hook/push/1');

# Creating a new issue
$project = new \Gitlab\Model\Project(1, $client);
$issue = $project->createIssue('This does not work.', array(
  'description' => 'This doesn\'t work properly. Please fix.',
  'assignee_id' => 2
));

# Closing that issue
$issue->close();

You get the idea! Take a look around (API methods, models) and please feel free to report any bugs.

Framework Integrations

If you have integrated GitLab into a popular PHP framework, let us know!

Contributing

There are many parts of Gitlab that I have not added to this as it was originally created for personal use, hence the lack of tests. Feel free to fork and add new functionality and tests, I'll gladly accept decent pull requests.

php-gitlab-api's People

Contributors

m4tthumphrey avatar fbourigault avatar m1guelpf avatar tobiasetter avatar gaooulong avatar jubianchi avatar radutopala avatar grahamcampbell avatar violuke avatar artistan avatar vinkla avatar alfredbez avatar cdaguerre avatar mujibazizi avatar moufmouf avatar glaubinix avatar c33s avatar shulard avatar edwinhoksberg avatar cschulz avatar cizel avatar benmag avatar aaa2000 avatar sschwarz avatar mykiwi avatar quentin-st avatar schneidermichal avatar greppy avatar kylewiering avatar donkidd avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.