Skip to content

cryptixcoder/aws-sdk-php-laravel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS Service Provider for Laravel 4

Latest Stable Version Total Downloads

A simple Laravel 5 service provider for including the AWS SDK for PHP.

Installation

The AWS Service Provider can be installed via Composer by requiring the aws/aws-sdk-php-laravel package in your project's composer.json.

{
    "require": {
        "aws/aws-sdk-php-laravel": "~2.0"
    }
}

Then run a composer update

php composer.phar update

Configuration

To use the AWS Service Provider, you must register the provider when bootstrapping your Laravel application.

By default, the package uses the following environment variables to auto-configure the plugin without modification:

AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_REGION              // default = us-east-1
AWS_CONFIG_FILE         // default = null

To customize the configuration file, publish the package configuration using Artisan.

php artisan vendor:publish

Update your settings in the generated app/config/aws.php configuration file.

return [
    'key'         => 'YOUR_AWS_ACCESS_KEY_ID',
    'secret'      => 'YOUR_AWS_SECRET_KEY',
    'region'      => 'us-east-1',
    'config_file' => null,
];

Find the providers key in your app/config/app.php and register the AWS Service Provider.

    'providers' => array(
        // ...
        'Aws\Laravel\AwsServiceProvider',
    )

Find the aliases key in your app/config/app.php and add the AWS facade alias.

    'aliases' => array(
        // ...
        'AWS' => 'Aws\Laravel\AwsFacade',
    )

Usage

In order to use the AWS SDK for PHP within your app, you need to retrieve it from the Laravel IoC Container. The following example uses the Amazon S3 client to upload a file.

$s3 = App::make('aws')->get('s3');
$s3->putObject(array(
    'Bucket'     => 'YOUR_BUCKET',
    'Key'        => 'YOUR_OBJECT_KEY',
    'SourceFile' => '/the/path/to/the/file/you/are/uploading.ext',
));

If the AWS facade is registered within the aliases section of the application configuration, you can also use the following technique.

$s3 = AWS::get('s3');
$s3->putObject(array(
    'Bucket'     => 'YOUR_BUCKET',
    'Key'        => 'YOUR_OBJECT_KEY',
    'SourceFile' => '/the/path/to/the/file/you/are/uploading.ext',
));

Links

About

A Laravel 5 (and 4) service provider for the AWS SDK for PHP

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.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