PHP code example of flownative / harbor-api-client

1. Go to this page and download the library: Download flownative/harbor-api-client 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/ */

    

flownative / harbor-api-client example snippets


use Http\Client\Common\Plugin\AddHostPlugin;
use Http\Client\Common\Plugin\AddPathPlugin;
use Http\Client\Common\Plugin\AuthenticationPlugin;
use Http\Message\Authentication\BasicAuth;
use Flownative\Harbor\Api\Model\ProjectReq;

…

$client = \Flownative\Harbor\Api\Client::create(
    null,
    [
        new AddHostPlugin(
            $endpointUri
        ),
        new AddPathPlugin(
            $endpointUri
        ),
        new AuthenticationPlugin(
            new BasicAuth(
                $username,
                $password,
            )
        )
    ]
);

$projectRequest = new ProjectReq();
$projectRequest
    ->setProjectName((string)$projectName)
    ->setPublic(false);

$client->createProject($projectRequest);