Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9b8ad50

Browse files
committed
Added some documentation
1 parent 6a6338a commit 9b8ad50

1 file changed

Lines changed: 81 additions & 1 deletion

File tree

README.md

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,88 @@
1-
php-gitlab-api
1+
A PHP Wrapper for use with the [Gitlab API](https://github.com/gitlabhq/gitlabhq/tree/master/doc/api).
22
==============
33

44
Based on [php-github-api](https://github.com/m4tthumphrey/php-github-api) and code from [KnpLabs](https://github.com/KnpLabs/php-github-api).
55

6+
Installation
7+
------------
8+
Install Composer
9+
10+
```
11+
$ curl -sS https://getcomposer.org/installer | php
12+
$ sudo mv composer.phar /usr/local/bin/composer
13+
```
14+
15+
Add the following to your require block in composer.json config:
16+
17+
```
18+
"m4tthumphrey/php-gitlab-api": "dev-master"
19+
```
20+
21+
Include Composer's autoloader:
22+
23+
24+
```php
25+
require_once dirname(__DIR__).'/vendor/autoload.php';
26+
```
27+
28+
General API Usage
29+
-----------------
30+
31+
```php
32+
$gitlab = new \Gitlab\Client('http://git.yourdomain.com'/api/v3/'); // change here
33+
$gitlab->authenticate('your_gitlab_token_here', \Gitlab\Client::AUTH_URL_TOKEN); // change here
34+
35+
$project = $gitlab->api('projects')->create('My Project', array(
36+
'description' => 'This is a project'
37+
'issues_enabled' => false
38+
));
39+
40+
```
41+
42+
Model Usage
43+
-----------
44+
45+
You can also use the library in an object oriented manner.
46+
47+
```php
48+
$gitlab = new \Gitlab\Client('http://git.yourdomain.com'/api/v3/'); // change here
49+
$gitlab->authenticate('your_gitlab_token_here', \
50+
Gitlab\Client::AUTH_URL_TOKEN); // change here
51+
52+
// Give the API client instance to model classes
53+
\Gitlab\Model\AbstractModel::client($gitlab);
54+
```
55+
56+
Creating a new project
57+
58+
```php
59+
$project = \Gitlab\Model\Project::create('My Project', array(
60+
'description' => 'This is my project',
61+
'issues_enabled' => false
62+
));
63+
64+
$project->addHook('http://mydomain.com/hook/push/1');
65+
66+
```
67+
68+
Creating a new issue
69+
70+
```php
71+
$project = new \Gitlab\Model\Project(1);
72+
$issue = $project->createIssue('This does not work..', array(
73+
'description' => 'This doesnt work properly. Please fix',
74+
'assignee_id' => 2
75+
));
76+
```
77+
78+
Closing that issue
79+
80+
```php
81+
$issue->close();
82+
```
83+
84+
You get the idea! Take a look around and please feel free to report any bugs.
85+
686
Contributing
787
------------
888

0 commit comments

Comments
 (0)