PHP code example of mirkoschmidt / php-gitlab-api
1. Go to this page and download the library: Download mirkoschmidt/php-gitlab-api library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mirkoschmidt / php-gitlab-api example snippets
$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
));
$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']]);
$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();
bash
composer