Skip to content

Commit cefce9c

Browse files
Avoid deprecated code in the examples
1 parent 70dbac3 commit cefce9c

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

README.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,31 +49,33 @@ We are decoupled from any HTTP messaging client by using [PSR-7](https://www.php
4949

5050
```php
5151
// 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);
5554

5655
// 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);
6058

59+
// An example API call
6160
$project = $client->projects()->create('My Project', [
6261
'description' => 'This is a project',
6362
'issues_enabled' => false,
6463
]);
64+
```
65+
66+
## Self-Hosted GitLab
6567

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);
6672
```
6773

6874
## Example with Pager
6975

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

7278
```php
73-
$client = Gitlab\Client::create('http://git.yourdomain.com')
74-
->authenticate('your_gitlab_token_here', Gitlab\Client::AUTH_HTTP_TOKEN)
75-
;
76-
7779
$pager = new Gitlab\ResultPager($client);
7880
$issues = $pager->fetchAll($client->issues(), 'all', [null, ['state' => 'closed']]);
7981

@@ -84,17 +86,13 @@ $issues = $pager->fetchAll($client->issues(), 'all', [null, ['state' => 'closed'
8486
You can also use the library in an object oriented manner:
8587

8688
```php
87-
$client = Gitlab\Client::create('http://git.yourdomain.com')
88-
->authenticate('your_gitlab_token_here', Gitlab\Client::AUTH_HTTP_TOKEN)
89-
;
90-
9189
// Creating a new project
9290
$project = Gitlab\Model\Project::create($client, 'My Project', [
9391
'description' => 'This is my project',
9492
'issues_enabled' => false,
9593
]);
9694

97-
$project->addHook('http://mydomain.com/hook/push/1');
95+
$project->addHook('https://mydomain.com/hook/push/1');
9896

9997
// Creating a new issue
10098
$project = new Gitlab\Model\Project(1, $client);

0 commit comments

Comments
 (0)