From d2efbdf1e190e8ae6761c166b198004482eecc41 Mon Sep 17 00:00:00 2001 From: koolhead17 Date: Tue, 16 Aug 2016 17:30:47 -0700 Subject: [PATCH] Doc: Added cookbook for how to use AWS PHP sdk with Minio. (#67) --- README.md | 1 + docs/aws-sdk-for-php-with-minio.md | 67 ++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 docs/aws-sdk-for-php-with-minio.md diff --git a/README.md b/README.md index bf323ba..33690ff 100644 --- a/README.md +++ b/README.md @@ -31,3 +31,4 @@ Note: You can also refer to [Awesome Minio](https://github.com/minio/awesome-min - [Download from Browser with PreSignedGet](./docs/presigned-get-download-from-browser.md) - [Upload via Browser with PreSignedPut](./docs/presigned-put-upload-via-browser.md) - [How to use Cyberduck with Minio](./docs/how-to-use-cyberduck-with-minio.md) +- [How to use AWS SDK for PHP with Minio Server](./docs/aws-sdk-for-php-with-minio.md) diff --git a/docs/aws-sdk-for-php-with-minio.md b/docs/aws-sdk-for-php-with-minio.md new file mode 100644 index 0000000..a5396f3 --- /dev/null +++ b/docs/aws-sdk-for-php-with-minio.md @@ -0,0 +1,67 @@ +# How to use AWS SDK for PHP with Minio Server [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/minio/minio?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + +`aws-sdk-php` is the official AWS SDK for the PHP programming language. In this recipe we will learn how to use `aws-sdk-php` with Minio server. + + +## 1. Prerequisites + +Install Minio Server from [here](http://docs.minio.io/docs/minio). + +## 2. Installation + +Install `aws-sdk-php` from AWS SDK for PHP official docs [here](https://docs.aws.amazon.com/aws-sdk-php/v3/guide/getting-started/installation.html) + + +## 3. Example + +Please replace ``endpoint``,``credentials``, ``Bucket`` with your local setup in this ``example.php`` file. + +List all buckets on Minio server using aws-sdk-php. + + +```php + + 'latest', + 'region' => 'us-east-1', + 'endpoint' => 'http://localhost:9000', + 'credentials' => [ + 'key' => 'H5K8172RVM311Q2XFEHX', + 'secret' => '5bRnl3DGhNM+fRBMxOii11k8iT78cNSIfoqnJfwC', + ], +]); + + +// Send a PutObject request and get the result object. +$insert = $s3->putObject([ + 'Bucket' => 'testbucket', + 'Key' => 'testkey', + 'Body' => 'Hello from Minio!!' +]); + +// Download the contents of the object. +$retrive = $s3->getObject([ + 'Bucket' => 'testbucket', + 'Key' => 'testkey', + 'SaveAs' => 'testkey_local' +]); + +// Print the body of the result by indexing into the result object. +echo $retrive['Body']; + +``` + + +## 3. Run the Program + +```sh +$ php example.php +Hello from Minio!! + +```