Skip to main content

How to use the AWS SDK for PHP with Stook?

To use the PHP SDK, follow the steps below.

  • Install the AWS SDK for PHP.

  • Configure additional AWS CLI profiles for the Stook account using the Stook keys.

Below is a sample PHP file that configures the Stook Endpoint.

Example Code

CODE
<?php
require 'aws/aws-autoloader.php';

$s3 = new Aws\S3\S3Client([
    'version' => 'latest',
    'region'  => 'us-east-1',
    'endpoint' => 'Enter server info',
    'use_path_style_endpoint' => true,
    'credentials' => [
        'key'    =>  'Enter Access Key',
        'secret' => 'Enter Secret Key',
    ],
   'http'    => [
       'verify' => false
    ]
]);

try {
    $s3->createBucket(array('Bucket' => 'testbucket'));
}
catch (Exception $e){
    echo "There is a bucket with that name!<br>";
}

// Sending a PutObject request and getting the results
$insert = $s3->putObject([
    'Bucket' => 'testbucket',
    'Key'    => 'testkey',
    'Body'   => 'Hello world'
]);
// Download the contents of the object
$retrive = $s3->getObject([
    'Bucket' => 'testbucket',
    'Key'    => 'testkey',
    'SaveAs' => 'testkey_local'
]);
//Index the body to the result object
echo $retrive['Body'];

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.