Git Product home page Git Product logo

php-gitlab-api's Introduction

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

Build Status

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

Installation

  1. Install Composer

    $ curl -sS https://getcomposer.org/installer | php
    $ sudo mv composer.phar /usr/local/bin/composer
  2. Add the following to your require block in composer.json config.

    Note: be careful when using the dev-master tag as this may have unexpected results depending on your version of Gitlab. See the Versioning section below for more information.

    php composer.phar require m4tthumphrey/php-gitlab-api:dev-master

  3. Include Composer's autoloader:

    require_once dirname(__DIR__).'/vendor/autoload.php';

Versioning

From the 6.0 stable release of Gitlab, I shall now be matching the client version with the Gitlab version. For example when Gitlab 6.1 is released I will release version 6.1.0 of the API client. If I need to make future updates to the client before the next API version is released, I'll simply use a 3rd build version - 6.1.1, 6.1.2 etc for example.

It is recommended that you keep your composer file in sync with whatever version of Gitlab you are currently running: if you are using 6.0, you should require 6.0.*; 6.1 should be 6.1.*...

General API Usage

$client = new \Gitlab\Client('http://git.yourdomain.com/api/v3/');               // change here
$client->authenticate('your_gitlab_token_here', \Gitlab\Client::AUTH_URL_TOKEN); // change here

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

Model Usage

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

$client = new \Gitlab\Client('http://git.yourdomain.com/api/v3/');               // change here
$client->authenticate('your_gitlab_token_here', \Gitlab\Client::AUTH_URL_TOKEN); // change here

# 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

aaa2000 avatar alfredbez avatar beeglebug avatar benmag avatar brammeleman avatar chteuchteu avatar cizel avatar cschulz avatar dariuskt avatar davidkuridza avatar edwinhoksberg avatar glaubinix avatar gonimar avatar greppy avatar jubianchi avatar m4tthumphrey avatar mujibazizi avatar radutopala avatar rkallenkoot avatar schneidermichal avatar scottrobertson avatar shulard avatar sschwarz avatar theaxiom avatar thomasvargiu avatar tomcan avatar tyler-sommer avatar vetruvet avatar vinkla avatar visualq avatar

Watchers

 avatar  avatar  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.