PHP Bitbucket API

Simple Bitbucket API wrapper for PHP

Repository

Allows you to create a new repository or edit a specific one.

Prepare:

// @see: https://bitbucket.org/account/user/<username or team>/api
$oauth_params = array(
    'client_id'         => 'aaa',
    'client_secret'     => 'bbb'
);

$repo = new \Bitbucket\API\Repositories\Repository();
$repo->getClient()->addListener(
    new \Bitbucket\API\Http\Listener\OAuth2Listener($oauth_params)
);

Get information associated with an individual repository: (API 2.0)

$repo->get($account_name, $repo_slug);

Create a new repository: (API 1.0)

NOTE: API 1.0 endpoint for repository creation has been deprecated, so please use the new API 2.0 endpoint described bellow.

$repo->create($repo_slug, array(
    'description'   => 'My super secret project.',
    'language'      => 'php',
    'is_private'    => true
));

Create a new repository: (API 2.0)

$repo->create($account_name, $repo_slug, array(
    'scm'               => 'git',
    'description'       => 'My super secret project.',
    'language'          => 'php',
    'is_private'        => true,
    'fork_policy'       => 'no_public_forks',
));

Update an existing repository:

$repo->update($account_name, $repo_slug, array(
    'description'   => 'My super secret project !!!',
    'language'      => 'php',
    'is_private'    => true
));

Delete a repository: (API 2.0)

$repo->delete($account_name, $repo_slug);

Get the list of accounts watching a repository: (API 2.0)

$repo->watchers($account_name, $repo_slug);

Get the list of repository forks: (API 2.0)

$repo->forks($account_name, $repo_slug);

Fork a repository:

$repo->fork($account_name, $repo_slug, $fork_slug, array(
    'is_private' => true
));

Get a list of branches associated with a repository:

$repo->branches($account_name, $repo_slug);

Get the repository's main branch:

$repo->branch($account_name, $repo_slug);

Get the repository manifest:

$repo->manifest($account_name, $repo_slug, 'develop');

Get a list of tags:

$repo->tags($account_name, $repo_slug);

Get the raw content of a file or directory:

$repo->raw($account_name, $repo_slug, '1bc8345', 'app/models/core.php')

Get the history of a file in a changeset

$repo->filehistory($account_name, $repo_slug, '1bc8345', 'app/models/core.php')