PHP code example of lbausch / ceph-radosgw-admin

1. Go to this page and download the library: Download lbausch/ceph-radosgw-admin 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/ */

    

lbausch / ceph-radosgw-admin example snippets


use LBausch\CephRadosgwAdmin\Client;

ay:8080', 'access key', 'secret key');

$response = $client->bucket()->list();

print_r($response->get());

/*
Array
(
    [0] => mybucket
)
*/

use LBausch\CephRadosgwAdmin\ApiException;
use LBausch\CephRadosgwAdmin\Client;

 {
    $client->user()->remove('non existent user');
} catch (ApiException $exception) {
    // Exception handling
}


use LBausch\CephRadosgwAdmin\Client;

ay:8080', 'access key', 'secret key');

$s3client = $client->getS3Client();

// Use different credentials
// $s3client = $client->getS3Client('different access key', 'different secret key');

// Pass arbitrary options to S3 client
// $s3client = $client->getS3Client('different access key', 'different secret key', [
//     'http' => [
//         'verify' => false,
//     ],
// ]);

// Create a bucket
$s3client->createBucket([
    'Bucket' => 'mybucket',
]);

// List all buckets
$buckets = $s3client->listBuckets();

foreach ($buckets['Buckets'] as $bucket) {
    echo $bucket['Name'].PHP_EOL; // mybucket
}

// Put an object in the bucket
$s3client->putObject([
    'Bucket' => 'mybucket',
    'SourceFile' => 'foobar.png',
    'Key' => 'foobar.png',
]);

use LBausch\CephRadosgwAdmin\Client;
use LBausch\CephRadosgwAdmin\Config;

> 'mgt/',
]);

// Override settings after instantiation, e.g. specify a timeout for requests
$config->set('httpClientConfig', [
    'timeout' => 10,
]);

$client = Client::make('http://gateway:8080', 'access key', 'secret key', $config);