ublaboo / aws-sdk-nette-extension
A Nette extension for the AWS SDK for PHP http://aws.amazon.com/sdkforphp/
Installs: 19 497
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 3
Forks: 4
Open Issues: 0
Requires
- aws/aws-sdk-php: ~3.0
- nette/di: ^2.3|^2.4|^3.0
Requires (Dev)
- mockery/mockery: ~0.9
- nette/tester: ~1.6.1
This package is auto-updated.
Last update: 2024-12-20 06:57:54 UTC
README
aws-sdk-nette-extension
A Nette extension for the AWS SDK for PHP http://aws.amazon.com/sdkforphp/
Installation
Download extension using composer
composer require ublaboo/aws-sdk-nette-extension
Register extension in your config.neon file:
extensions:
aws: Ublaboo\AwsSdkNetteExtension\DI\AwsSdkNetteExtension
Configuration
Configure extension in your config.neon
file:
aws:
region: eu-west-1
version: latest
# settings for interacting with other then Amazon endpoints
endpoint: (optional - when ommited, Amazon AWS URL is used)
use_path_style_endpoint: true|false (optional - default=false)
And put your key and secret in your config.local.neon
file (which should not be versioned)
aws:
credentials:
key: your_access_key
secret: your_secret_access_key
use_aws_shared_config_files: true|false (optional - default=true)
Usage
Ideally create some services wrapping the S3 client with your logic inside them
class S3Service { /** * @var \Aws\S3\S3Client */ public $s3; public function __construct(\Aws\S3\S3Client $s3) { $this->s3 = $s3; } public function save($path_to_file) { $this->s3->putObject([ 'Bucket' => 'YourBucket', 'Key' => 'YourObjectKey', 'SourceFile' => $path_to_file, ]); } }
And use them in your presenters:
class HomepagePresenter extends Presenter { /** * @var S3Service * @inject */ public $service; public function actionDefault() { $this->service->save('/path/to/file'); } }