@@ -49,31 +49,33 @@ We are decoupled from any HTTP messaging client by using [PSR-7](https://www.php
49
49
50
50
``` php
51
51
// Token authentication
52
- $client = Gitlab\Client::create('http://git.yourdomain.com')
53
- ->authenticate('your_gitlab_token_here', Gitlab\Client::AUTH_HTTP_TOKEN)
54
- ;
52
+ $client = new Gitlab\Client();
53
+ $client->authenticate('your_http_token', Gitlab\Client::AUTH_HTTP_TOKEN);
55
54
56
55
// OAuth2 authentication
57
- $client = Gitlab\Client::create('http://gitlab.yourdomain.com')
58
- ->authenticate('your_gitlab_token_here', Gitlab\Client::AUTH_OAUTH_TOKEN)
59
- ;
56
+ $client = new Gitlab\Client();
57
+ $client->authenticate('your_oauth_token', Gitlab\Client::AUTH_OAUTH_TOKEN);
60
58
59
+ // An example API call
61
60
$project = $client->projects()->create('My Project', [
62
61
'description' => 'This is a project',
63
62
'issues_enabled' => false,
64
63
]);
64
+ ```
65
+
66
+ ## Self-Hosted GitLab
65
67
68
+ ``` php
69
+ $client = new Gitlab\Client();
70
+ $client->setUrl('https://git.yourdomain.com');
71
+ $client->authenticate('your_http_token', Gitlab\Client::AUTH_HTTP_TOKEN);
66
72
```
67
73
68
74
## Example with Pager
69
75
70
76
to fetch all your closed issue with pagination ( on the gitlab api )
71
77
72
78
``` php
73
- $client = Gitlab\Client::create('http://git.yourdomain.com')
74
- ->authenticate('your_gitlab_token_here', Gitlab\Client::AUTH_HTTP_TOKEN)
75
- ;
76
-
77
79
$pager = new Gitlab\ResultPager($client);
78
80
$issues = $pager->fetchAll($client->issues(), 'all', [null, ['state' => 'closed']]);
79
81
@@ -84,17 +86,13 @@ $issues = $pager->fetchAll($client->issues(), 'all', [null, ['state' => 'closed'
84
86
You can also use the library in an object oriented manner:
85
87
86
88
``` php
87
- $client = Gitlab\Client::create('http://git.yourdomain.com')
88
- ->authenticate('your_gitlab_token_here', Gitlab\Client::AUTH_HTTP_TOKEN)
89
- ;
90
-
91
89
// Creating a new project
92
90
$project = Gitlab\Model\Project::create($client, 'My Project', [
93
91
'description' => 'This is my project',
94
92
'issues_enabled' => false,
95
93
]);
96
94
97
- $project->addHook('http ://mydomain.com/hook/push/1');
95
+ $project->addHook('https ://mydomain.com/hook/push/1');
98
96
99
97
// Creating a new issue
100
98
$project = new Gitlab\Model\Project(1, $client);
0 commit comments