PHP code example of aws / aws-sdk-php-laravel
1. Go to this page and download the library: Download aws/aws-sdk-php-laravel 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/ */
aws / aws-sdk-php-laravel example snippets
$app->register(Aws\Laravel\AwsServiceProvider::class);
'providers' => array(
// ...
Aws\Laravel\AwsServiceProvider::class,
)
'aliases' => array(
// ...
'AWS' => Aws\Laravel\AwsFacade::class,
)
return [
'credentials' => [
'key' => env('AWS_ACCESS_KEY_ID', ''),
'secret' => env('AWS_SECRET_ACCESS_KEY', ''),
],
'region' => env('AWS_REGION', 'us-east-1'),
'version' => 'latest',
// You can override settings for specific services
'Ses' => [
'region' => 'us-east-1',
],
];
$s3 = App::make('aws')->createClient('s3');
$s3->putObject(array(
'Bucket' => 'YOUR_BUCKET',
'Key' => 'YOUR_OBJECT_KEY',
'SourceFile' => '/the/path/to/the/file/you/are/uploading.ext',
));
$s3 = AWS::createClient('s3');
$s3->putObject(array(
'Bucket' => 'YOUR_BUCKET',
'Key' => 'YOUR_OBJECT_KEY',
'SourceFile' => '/the/path/to/the/file/you/are/uploading.ext',
));
$s3 = app('aws')->createClient('s3');
$s3->putObject(array(
'Bucket' => 'YOUR_BUCKET',
'Key' => 'YOUR_OBJECT_KEY',
'SourceFile' => '/the/path/to/the/file/you/are/uploading.ext',
));
json
{
"ws/aws-sdk-php-laravel": "~3.0"
}
}
sh
php composer.phar update
sh
php artisan vendor:publish --provider="Aws\Laravel\AwsServiceProvider"