定制 mvilab/bitbucket-laravel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mvilab/bitbucket-laravel

Composer 安装命令:

composer require mvilab/bitbucket-laravel

包简介

A Laravel package to interact with Bitbucket API, focusing on repository creation.

README 文档

README

Bitbucket Laravel is a Laravel package that integrates with the Bitbucket API to manage repositories, including creating new repositories within a workspace. This package is built on top of bitbucket/client and allows you to use the Bitbucket API in a Laravel-friendly way.

Installation

1. Install via Composer

You can install the package via Composer:

composer require mvilab/bitbucket-laravel

2. Add the Service Provider

Add the service provider to the providers array in config/app.php:

'providers' => [
    // Other service providers...
    MviLab\BitbucketLaravel\Service\BitbucketLaravelServiceProvider::class,
],

3. Configure the API Token

Add your Bitbucket API Token to the .env file:

BITBUCKET_TOKEN=your-bitbucket-api-token

Ensure the token has the appropriate permissions to access the workspace and create repositories.

Usage

Creating a New Repository

You can use the BitbucketService to create a new repository in Bitbucket. Here's an example of how to use it in a Laravel controller:

use MviLab\BitbucketLaravel\Service\BitbucketService;

class BitbucketController extends Controller
{
    protected $bitbucketService;

    public function __construct(BitbucketService $bitbucketService)
    {
        $this->bitbucketService = $bitbucketService;
    }

    public function createRepo()
    {
        $workspace = 'your-workspace';
        $repoName = 'new-repository';
        $options = [
            'is_private' => true,
            'scm' => 'git',  // SCM (Source Control Management), can be 'git' or 'hg'
            'description' => 'Repository created via API',
        ];

        $response = $this->bitbucketService->createRepository($workspace, $repoName, $options);

        return response()->json($response);
    }
}

Parameters for createRepository

  • $workspace: The name of the workspace in Bitbucket.
  • $repoName: The name of the repository to be created.
  • $options: An array with the repository configurations such as:
    • is_private: Set the repository as private or public.
    • scm: The type of SCM, either 'git' or 'hg'.
    • description: A description for the repository.

Example Response

If the repository is created successfully, the API will return a JSON response with the details of the newly created repository.

{
  "scm": "git",
  "website": null,
  "has_wiki": false,
  "uuid": "{repository-uuid}",
  "language": "",
  "fork_policy": "no_public_forks",
  "created_on": "2024-01-01T12:34:56.789Z",
  ...
}

Customization

If you need to extend the API functionality, you can easily do so by creating your own wrapper class or extending the service.

Testing

You can test the API functionality using Laravel's testing framework like PHPUnit or Pest.

Contributing

If you find any bugs or want to add new features, feel free to submit a pull request or open an issue.

统计信息

  • 总下载量: 87
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-06-14