Skip to content

Commit 17dd56c

Browse files
committed
[WIP] Updated README and package config file.
1 parent 23f939d commit 17dd56c

File tree

2 files changed

+71
-56
lines changed

2 files changed

+71
-56
lines changed

README.md

Lines changed: 24 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,28 @@ The AWS Service Provider can be installed via [Composer](http://getcomposer.org)
1818
}
1919
```
2020

21-
## Usage
21+
## Configuration
22+
23+
To use the AWS Service Provider, you must register the provider when bootstrapping your Laravel application.
2224

23-
To use the AWS Service Provider, you must register the provider when bootstrapping your Laravel application. There are
24-
essentially two ways to do this.
25+
Publish the package configuration using Artisan.
2526

26-
### 1. Use Laravel Configuration
27+
```sh
28+
php artisan config:publish aws/aws-sdk-php-laravel
29+
```
2730

28-
Create a new `app/config/aws.php` configuration file with the following options:
31+
Update your settings in the generated `app/config/packages/aws/aws-sdk-php-laravel` configuration file.
2932

3033
```php
3134
return array(
32-
'key' => '<your-aws-access-key-id>',
33-
'secret' => '<your-aws-secret-access-key>',
34-
'region' => Aws\Common\Enum\Region::US_WEST_2,
35+
'key' => 'YOUR_AWS_ACCESS_KEY_ID',
36+
'secret' => 'YOUR_AWS_SECRET_KEY',
37+
'region' => 'us-east-1',
38+
'config_file' => null,
3539
);
3640
```
3741

38-
Find the `providers` key in `app/config/app.php` and register the AWS Service Provider.
42+
Find the `providers` key in your `app/config/app.php` and register the AWS Service Provider.
3943

4044
```php
4145
'providers' => array(
@@ -44,7 +48,7 @@ Find the `providers` key in `app/config/app.php` and register the AWS Service Pr
4448
)
4549
```
4650

47-
Find the `aliases` key in `app/config/app.php` and add the AWS facade alias.
51+
Find the `aliases` key in your `app/config/app.php` and add the AWS facade alias.
4852

4953
```php
5054
'aliases' => array(
@@ -53,64 +57,29 @@ Find the `aliases` key in `app/config/app.php` and add the AWS facade alias.
5357
)
5458
```
5559

56-
### 2. Manual Instantiation
57-
58-
You can also register the provider and configuration options at runtime. This could be done in your global bootstrapping
59-
process in `app/start/global.php`.
60-
61-
```php
62-
use Aws\Common\Enum\Region;
63-
use Aws\Laravel\AwsServiceProvider;
64-
use Illuminate\Foundation\Application;
65-
66-
// Instantiate a new application. This is normally done by the Laravel framework and the instance is available in
67-
// `app/start/global.php` for you to use.
68-
$app = new Application;
69-
70-
// Register the AWS service provider and provide your configuration
71-
$app->register(new AwsServiceProvider($app), array(
72-
'config' => array(
73-
'aws' => array(
74-
'key' => '<your-aws-access-key-id>',
75-
'secret' => '<your-aws-secret-access-key>',
76-
'region' => Region::US_WEST_2,
77-
),
78-
),
79-
));
80-
```
81-
82-
You can alternatively specify the path to an AWS config file (see [AWS SDK for PHP](http://github.com/aws/aws-sdk-php)
83-
for details about how to format this type of file).
84-
85-
```php
86-
$app->register(new AwsServiceProvider($app), array('config' => array('aws' => '/path/to/aws/config/file.php')));
87-
```
88-
89-
Either way, the value of `$app['config']['aws']` is passed directly into `Aws\Common\Aws::factory()`.
90-
91-
### Retrieving and Using a Service Client
60+
## Usage
9261

93-
In order to use the SDK from within your app, you need to retrieve it from the [Laravel IoC
62+
In order to use the AWS SDK for PHP within your app, you need to retrieve it from the [Laravel IoC
9463
Container](http://four.laravel.com/docs/ioc). The following example uses the Amazon S3 client to upload a file.
9564

9665
```php
9766
$s3 = App::make('aws')->get('s3');
9867
$s3->putObject(array(
99-
'Bucket' => '<your-bucket>',
100-
'Key' => '<the-name-of-your-object>',
101-
'SourceFile' => '/path/to/the/file/you/are/uploading.ext',
68+
'Bucket' => 'YOUR_BUCKET',
69+
'Key' => 'YOUR_OBJECT_KEY',
70+
'SourceFile' => '/the/path/to/the/file/you/are/uploading.ext',
10271
));
10372
```
10473

105-
If the AWS Facade is registered within the `aliases` section of the application configuration, you can use
106-
the following more expressive method.
74+
If the AWS facade is registered within the `aliases` section of the application configuration, you can also use the
75+
following technique.
10776

10877
```php
10978
$s3 = AWS::get('s3');
11079
$s3->putObject(array(
111-
'Bucket' => '<your-bucket>',
112-
'Key' => '<the-name-of-your-object>',
113-
'SourceFile' => '/path/to/the/file/you/are/uploading.ext',
80+
'Bucket' => 'YOUR_BUCKET',
81+
'Key' => 'YOUR_OBJECT_KEY',
82+
'SourceFile' => '/the/path/to/the/file/you/are/uploading.ext',
11483
));
11584
```
11685

src/config/config.php

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,53 @@
11
<?php
22

33
return array(
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Your AWS Credentials
8+
|--------------------------------------------------------------------------
9+
|
10+
| In order to communicate with an AWS service, you must provide your AWS
11+
| credentials including your AWS Access Key ID and your AWS Secret Key. You
12+
| can obtain these keys by logging into your AWS account and visiting
13+
| https://console.aws.amazon.com/iam/home?#security_credential.
14+
|
15+
| To use credentials from your environment or to use IAM Instance Profile
16+
| credentials, please remove these config settings from your config. For
17+
| more information see http://docs.aws.amazon.com/aws-sdk-php-2/guide/latest/configuration.html
18+
|
19+
*/
420
'key' => 'YOUR_AWS_ACCESS_KEY_ID',
521
'secret' => 'YOUR_AWS_SECRET_KEY',
6-
//'region' => 'YOUR_REGION',
22+
23+
/*
24+
|--------------------------------------------------------------------------
25+
| AWS Region
26+
|--------------------------------------------------------------------------
27+
|
28+
| Many AWS services are available in multiple regions. You should specify
29+
| the AWS region you would like to use, but please remember that not every
30+
| service is available in every region.
31+
|
32+
| These are the regions: us-east-1, us-west-1, us-west-2, us-gov-west-1
33+
| eu-west-1, sa-east-1, ap-northeast-1, ap-southeast-1, ap-southeast-2
34+
|
35+
*/
36+
'region' => 'us-east-1',
37+
38+
/*
39+
|--------------------------------------------------------------------------
40+
| AWS Config File Location
41+
|--------------------------------------------------------------------------
42+
|
43+
| Instead of specifying your credentials and region here, you can specify
44+
| the location of an AWS SDK for PHP config file to use. These files provide
45+
| more granular control over what credentials and regions you are using for
46+
| each service. If you specify a filepath for this configuration setting,
47+
| the others in this file will be ignored. See the SDK user guide for more
48+
| information: http://docs.aws.amazon.com/aws-sdk-php-2/guide/latest/configuration.html#using-a-custom-configuration-file
49+
|
50+
*/
51+
'config_file' => null,
52+
753
);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy