@@ -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
3134return 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
9463Container] ( 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
0 commit comments