• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. Developer Guide (PHP SDK)
  4. Initialization
  5. Creating an Instance of ObsClient

Creating an Instance of ObsClient

By Using the Constructor

// Declare the namespace.
use Obs\S3\ObsClient;

// Create an instance of ObsClient.
$obsClient = new ObsClient([
              'key' => '*** Provide your Access Key ***',
              'secret' => '*** Provide your Secret Key ***',
              'endpoint' => 'https://yourdomainname',
]);

// Use the instance to access OBS.

// Close obsClient.
$obsClient -> close();

By Using the Factory Method

// Declare the namespace.
use Obs\S3\ObsClient;

$endPoint = 'https://yourdomainname';

$ak = '*** Provide your Access Key ***';

$sk = '*** Provide your Secret Key ***';

// Create an instance of ObsClient.
$obsClient = ObsClient::factory ( [
    'key' => $ak,
    'secret' => $sk,
    'endpoint' => $endPoint
]);

// Use the instance to access OBS.

// Close obsClient.
$obsClient -> close();
NOTE:
  • The project can contain one or more instances of ObsClient.
  • After you call the ObsClient -> close method to close an instance of ObsClient, the instance cannot be used any more.