PHP code example of reliv / aws-sdk-php-zf2-zf3fc

1. Go to this page and download the library: Download reliv/aws-sdk-php-zf2-zf3fc 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/ */

    

reliv / aws-sdk-php-zf2-zf3fc example snippets


return array(
    'modules' => array(
        'Aws'
    )
);



return array(
    'components' => array(
        'rcm' => array(
            'AwsComponent' => array(
                'key'    => '<your-aws-access-key-id>',
                'secret' => '<your-aws-secret-access-key>',
                'region' => 'us-west-2'
            )
        )
    )
);

public function indexAction()
{
    $aws    = $this->getServiceLocator()->get('aws');
    $client = $aws->get('dynamodb');

    $table = 'posts';

    // Create a "posts" table
    $result = $client->createTable(array(
        'TableName' => $table,
        'KeySchema' => array(
            'HashKeyElement' => array(
                'AttributeName' => 'slug',
                'AttributeType' => 'S'
            )
        ),
        'ProvisionedThroughput' => array(
            'ReadCapacityUnits'  => 10,
            'WriteCapacityUnits' => 5
        )
    ));

    // Wait until the table is created and active
    $client->waitUntilTableExists(array('TableName' => $table));

    echo "The {$table} table has been created.\n";
}

 echo $this->s3Link('my-object', 'my-bucket');


    $this->s3Link->setDefaultBucket('my-bucket');
    echo $this->s3Link('my-object');

 echo $this->s3Link('my-object', 'my-bucket', '+10 minutes');

 echo $this->cloudFrontLink('my-object', 'my-domain');


    $this->cloudFrontLink->setDefaultDomain('my-domain');
    echo $this->cloudFrontLink('my-object');

 echo $this->cloudFrontLink('my-object', 'my-bucket', time() + 60);

$request = new Request();
$files   = $request->getFiles();
// e.g., $files['my-upload']['tmp_name'] === '/tmp/php5Wx0aJ'
// e.g., $files['my-upload']['name'] === 'profile-picture.jpg'

// Fetch the filter from the Filter Plugin Manager to automatically handle dependencies
$filter = $serviceLocator->get('FilterManager')->get('S3RenameUpload');

$filter->setOptions(array(
    'bucket'    => 'my-bucket',
    'target'    => 'users/5/profile-picture.jpg',
    'overwrite' => true
));

$filter->filter($files['my-upload']);

// File has been renamed and moved to 'my-bucket' bucket, inside the 'users/5' path

use Zend\Session\SessionManager;

// Assume we are in a context where $serviceLocator is a ZF2 service locator.

$saveHandler = $serviceLocator->get('Aws\Session\SaveHandler\DynamoDb');

$manager = new SessionManager();
$manager->setSaveHandler($saveHandler);
json
{
    "ws/aws-sdk-php-zf2": "1.2.*"
    }
}