Code Monkey home page Code Monkey logo

aws-sdk-php-laravel's Introduction

AWS Service Provider for Laravel 4

Latest Stable Version Total Downloads

A simple Laravel 4 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": "1.*"
    }
}

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.

Publish the package configuration using Artisan.

php artisan config:publish aws/aws-sdk-php-laravel

Update your settings in the generated app/config/packages/aws/aws-sdk-php-laravel configuration file.

return array(
    '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

aws-sdk-php-laravel's People

Contributors

jeremeamia avatar aykutfarsak avatar jasonlewis avatar daylerees avatar grahamcampbell avatar digitalfiz avatar

Watchers

James Cloos avatar Peter Levin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.