@@ -18,24 +18,28 @@ The AWS Service Provider can be installed via [Composer](http://getcomposer.org)
18
18
}
19
19
```
20
20
21
- ## Usage
21
+ ## Configuration
22
+
23
+ To use the AWS Service Provider, you must register the provider when bootstrapping your Laravel application.
22
24
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.
25
26
26
- ### 1. Use Laravel Configuration
27
+ ``` sh
28
+ php artisan config:publish aws/aws-sdk-php-laravel
29
+ ```
27
30
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.
29
32
30
33
``` php
31
34
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,
35
39
);
36
40
```
37
41
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.
39
43
40
44
``` php
41
45
'providers' => array(
@@ -44,7 +48,7 @@ Find the `providers` key in `app/config/app.php` and register the AWS Service Pr
44
48
)
45
49
```
46
50
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.
48
52
49
53
``` php
50
54
'aliases' => array(
@@ -53,64 +57,29 @@ Find the `aliases` key in `app/config/app.php` and add the AWS facade alias.
53
57
)
54
58
```
55
59
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
92
61
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
94
63
Container] ( http://four.laravel.com/docs/ioc ) . The following example uses the Amazon S3 client to upload a file.
95
64
96
65
``` php
97
66
$s3 = App::make('aws')->get('s3');
98
67
$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',
102
71
));
103
72
```
104
73
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 .
107
76
108
77
``` php
109
78
$s3 = AWS::get('s3');
110
79
$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',
114
83
));
115
84
```
116
85
0 commit comments