gitlabphp / client Goto Github PK
View Code? Open in Web Editor NEWGitLab API v4 client for PHP
License: MIT License
GitLab API v4 client for PHP
License: MIT License
Could you please release tags to make it more stable/predictable for users to deploy.
I think there is something wrong with function encodePath in AbstractApi.php line 122
As Gitlab documentation says "make sure that the NAMESPACE/PROJECT_NAME is URL-encoded, eg. /api/v3/projects/diaspora%2Fdiaspora (where / is represented by %2F)."
line: rawurlencode($path); encodes path as documentation describes and
line: return str_replace(array('%2F', '.'), array('/', '%2E'), $path)
changes it back
result is 404 error
[07/May/2015:20:29:31 +0200] "GET /api/v3/projects/dd/dd?private_token=
I use earlier version of php-gitlab-api in one of my projects and it works fine
The Gitlab\HttpClient\Listener\ErrorListener
will produce a Fatal error (Wrong parameters for ErrorException) when the Gitlab API returns a error message that contains an array instead of a string message. Offending line: 46
{"message":{"path":["has already been taken"]}}
This will mostly happen when an data validation error occurs. See Data validation and error reporting for possible response formats.
A simple solution could be to json encode the message when it's not a string.
Used versions: GitLab 7.4.0; GitLab API v3
http://www.php-fig.org/psr/psr-4/
This enables us to have a VendorName\PackageName namespace. I would suggest "php-gitlab-api\php-gitlab-api" as the vendor\package names. this may be better suited then in a GitHub organisation.
It would also allow the code structure to be a little bit neater.
It would also make the suggested adapter packages a little neater and easier to find.
Thoughts?
I can't use cURL on some of my servers. Your library works fine, but it requires cURL. Is it possible to use Buzz library for HTTP requests in future? Buzz is a lightweight PHP 5.3 library for issuing HTTP requests.
https://github.com/kriswallsmith/Buzz
could you please tag a new stable release? to be able to use e.g. MergeRequest::opened
and rely on stable versions
use Gitlab\Client;
use Gitlab\Model\Project;
use Gitlab\Model\Issue;
$client = new Client('http://git.yourdomain.com/api/v3/'); // change here
$client->authenticate('your_gitlab_token_here', Client::AUTH_URL_TOKEN); // change here
$project = new Project($client);
$project->name = 'A project';
$project->description = 'This is a project';
$project->save();
The following block
$issue = new Issue($client);
$issue->title = 'This is an issue';
$issue->addLabel('bug');
$issue->save();
$project->addIssue($issue);
// or
$issue->project = $project;
would be the same as
$project->createIssue('This is an issue', array(
'labels' => array('bug')
));
Hi,
I run this command
$client->api('users')->create('[email protected]','test',array('name'=>'name','username'=>'username'));
I get an error like follows:
PHP Fatal error: Uncaught exception 'Gitlab\Exception\ErrorException' with message '400 (Bad request) "email" not given' in /home/damian/public_html/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/HttpClient/Listener/ErrorListener.php:47
Not sure if this is a bug or something wrong with my setup?
Cheers
Is there a reason that there is no functions in Gitlab\Api\Users for updating/deleting a user in gitlab?
I'd be happy to add the functionality and make a pull request just wanted to ask why first or Is it just that you didn't the functionality personally (like you said in the readme)?
Or could we just make the functions delete and put in Gitlab\Api\AbstractApi public rather than protected so they can be called on an instance of Gitlab\Api\Users (again happy to do it just wanted to ask)?
Hi,
I think it could be nice to search projects using per_page & page parameters
Parameters:
Best,
G.
I tried to create a new project using the example but it seems I get this error every time:
PHP Fatal error: Uncaught exception 'Gitlab\Exception\ErrorException' with message '400 (Bad request) "name" not given'
I use the hosted GitLab at gitlab.com.
Noticed a debug()
statement in there today... woops. ๐
The tag push events have been added to Gitlab API v7.4.0.rc1 (gitlabhq/gitlabhq@b4963e9)
What would be required to implement such feature? I was about to propose a merge request but I guess it's a bit more complicated and would require to implement all changes from Gitlab 6.9.1, according to the versionning policy.
Thanks you
I have heard complaints that this library does not use guzzle3 or 4.
It seems like is the only library around for gitlab that is more downloaded so far in packagist.
This ticket is to reference https://github.com/gushphp/gush-gitlab-adapter/blob/master/src/Adapter/GitLabAdapter.php#L86 and also asking for help integrating your library in.
We will first make it work then proceed to rewrite so it will use guzzle4 maybe.
Encouragements and thanks, feel welcome to contribute to Gush and join the core team ๐ถ
There's an issue with the tree function to access subfolders. It doesn't append the 'path' argument value to the url.
Example:
/repository/branches/[branchname]/[project id]/repository/tree/[path]
I've created a Symfony2 Bundle to use your library easy in Symfony. Maybe you want to link it in your readme file?
Add the ability to transfer project to a group as the gitlab API already supports it.
What should be the minimum supported version of PHP? Considering 5.3 was released over 5 years ago and that 5.6 was recently released, I would suggest the library targets no less that 5.5.
I can't work out what I'm doing wrong. I've got the following code:
<?php
require 'vendor/autoload.php';
$client = new \Gitlab\Client('https://gitlab.example.com/api/v3/'); // change here
$client->authenticate('not_actually_real', \Gitlab\Client::AUTH_URL_TOKEN); // change here
$project = new \Gitlab\Model\Project(17, $client);
$snippet = $project->createSnippet('title', 'someting.txt', 'code_is_cool');
?>
But I'm getting the following error:
Fatal error: Uncaught exception 'Gitlab\Exception\InvalidArgumentException' in /gitlab/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Client.php:115
Stack trace:
#0 /gitlab/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/AbstractModel.php(31): Gitlab\Client->api('snippets')
#1 /gitlab/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Project.php(464): Gitlab\Model\AbstractModel->api('snippets')
#2 /gitlab/test.php(24): Gitlab\Model\Project->createSnippet('title', 'someting.txt', 'code_is_cool')
#3 {main}
thrown in /gitlab/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Client.php on line 115
What am I doing wrong?
Is it possible to create a project in a namespace with your wrapper?
I don't see how to set the namespace ID.
I did find this https://groups.google.com/forum/#!topic/gitlabhq/x7MOmJGWLSc
So it is possible with the API, was scratching my head because it wasn't in the API documentation either.
The latest commit to master introduces a breaking change when managing project hooks.
Before the method signature for Api\Projects::addHook()
was as follows:
public function addHook($project_id, $url, $push_events = true, $issues_events = false, $merge_requests_events = false, $tag_push_events = false)
It is now
public function addHook($project_id, $url, array $params = array('push_events' => true))
This allows the user to specify a URL (required field) and then pass an optional list of event types. As you can see, push_events
are enabled by default.
Before the method signature for Api\Projects::updateHook()
was as follows:
public function updateHook($project_id, $url, $push_events = true, $issues_events = false, $merge_requests_events = false, $tag_push_events = false)
It is now
public function addHook($project_id, array $params = array())
This allows the user to only update the fields they required.
This also affects the corresponding methods in Model\Project
public function addHook($url, array $events = array())
public function updateHook($hook_id, array $params)
This will be released (tagged) in the 7.9 release next month.
previous: #32
The library uses buzz introducing yet another dep in gush. We can move it to guzzle 4 which is suit. In addition we should start semver also bugfixes so we can change https://github.com/gushphp/gush-gitlab-adapter/blob/master/composer.json#L5 which is a mistake on the version this should require.
Gitlab support works more or less, I have tried it before. Not sure if there were things that worked differently or need more support. So if we have request please let us open tickets on gush-gitlab-adapter /cc @matthiasnoback
I was wondering if i can use it with gitlab.com repos . I was unable to decide what the host param will be if using with gitlab.com
$client = new \Gitlab\Client('https://git.yourdomain.com/api/v3/'); // change here
I see that attachment you can add only to the comment, but api comments neither issues doesnt support attachments?
IE
$project = new Project($client, 1);
instead of
$project = new Project(1, $client);
This would make $client
mandatory but it is always passed anyway so do not see any disadvantages to this.
First thanks for this API, it works well and looks to save myself and others a ton of time.
I'm currently looking to retrieve a file contents from a given repo. I'm using the following:
$project = $client->api('repositories')->getFile( $project_id, $file_path, $ref );
which does work, but the content appears to be truncated. I know that GitHub API limits file sizes, and I haven't been able to determine if GitLabs is doing the same, my file is 4KB.
I've also tried using the blob()
method.
Replace all usage of urlencode()
to rawurlencode()
I have install gitlab CE in my local server and i also wanted to develop an php based application for using gitlab as Oauth2service provider . so im wondering how it will be achieved. I got up with this package and read all the documentation in read me file but one question remains me to start nothing that is where do i get a token. i have created a application in my gitlab and i have now app-id , secrete and callback url.. please help me.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.