PHP code example of graham-campbell / bitbucket

1. Go to this page and download the library: Download graham-campbell/bitbucket 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/ */

    

graham-campbell / bitbucket example snippets


        'Bitbucket' => GrahamCampbell\Bitbucket\Facades\Bitbucket::class,

use GrahamCampbell\Bitbucket\Facades\Bitbucket;
// you can alias this in config/app.php if you like

Bitbucket::currentUser()->show();
// we're done here - how easy was that, it just works!

use GrahamCampbell\Bitbucket\Facades\Bitbucket;

// writing this:
Bitbucket::connection('main')->currentUser()->show();

// is identical to writing this:
Bitbucket::currentUser()->show();

// and is also identical to writing this:
Bitbucket::connection()->currentUser()->show();

// this is because the main connection is configured to be the default
Bitbucket::getDefaultConnection(); // this will return main

// we can change the default connection
Bitbucket::setDefaultConnection('alternative'); // the default is now alternative

// Get all the repositories info
Bitbucket::repositories()->list();

// Get all the repositories info filtered by workspace
Bitbucket::repositories()->workspaces('example')->list();

use GrahamCampbell\Bitbucket\BitbucketManager;

class Foo
{
    private BitbucketManager $bitbucket;

    public function __construct(BitbucketManager $bitbucket)
    {
        $this->bitbucket = $bitbucket;
    }

    public function bar()
    {
        $this->bitbucket->currentUser()->show();
    }
}

app(Foo::class)->bar();
bash
$ php artisan vendor:publish