Bundle not maintained anymore - please use the Cisco Gitlab Bundle instead.
The GitlabBundle offers basic integration of the API introduced in Gitlab 2.7
So far only the Gitlab API v2 is implemented. It can easily be extended to include the Gitlab API v3 and the Github API v3. Merge requests welcome.
You'll need both the Buzz library and this bundle. Installation depends on how your project is set up:
Add the following lines in your composer.json
{
"repositories": [
{
"type": "git",
"url": "http://github.com/WrittenGames/GitlabBundle.git"
}
],
"require": {
"writtengames/gitlab-bundle": "*"
}
}
Run composer.phar and skip to Step 3.
If you're using the bin/vendors.php
method to manage your vendor libraries,
add the following entries to the deps
file at the root of your project file:
[buzz]
git=http://github.com/kriswallsmith/Buzz.git
[WGGitlabBundle]
git=http://github.com/WrittenGames/GitlabBundle.git
target=bundles/WG/GitlabBundle
Next, update your vendors by running:
$ ./bin/vendors install
Great! Now skip down to Step 2.
If you're managing your vendor libraries with submodules, simply add the two following submodules:
$ git submodule add git://github.com/kriswallsmith/Buzz.git vendor/buzz
$ git submodule add git://github.com/WrittenGames/GitlabBundle.git vendor/bundles/WG/GitlabBundle
Finally update your submodules:
$ git submodule init
$ git submodule update
Add the following entries to your autoloader:
<?php
// app/autoload.php
$loader->registerNamespaces(array(
// ...
'Buzz' => __DIR__.'/../vendor/buzz/lib',
'WG' => __DIR__.'/../vendor/bundles',
));
Enable the bundle in the kernel:
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new WG\GitlabBundle\WGGitlabBundle(),
);
}
php app/console doctrine:schema:update --force
Congratulations! You're ready to use the GitlabBundle!
<?php
// Get credentials containing a user's token, a Gitlab host and an API version, e.g. via a form
$access = $this->getDoctrine()->getRepository( 'WGGitlabBundle:Access' )->find( $someId );
// Obtain an API implementation instance for provided credentials
$api = $this->get( 'gitlab' )->getApi( $access );
// Call methods defined in WG\GitlabBundle\API\ApiInterface
$projects = $api->getProjects();
$issues = $api->getIssues();
Complete examples can be found in the built-in controllers.
Your users will need to enter a Gitlab host and private token in their profile before they can use the API. This bundle offers a controller and templates for doing that which only need to be included in your routing, and/or overridden in your application.
This bundle currently requires the Doctrine ORM. I may decide to make it storage agnostic in a future version.