GithubHelp home page GithubHelp logo

ingageco / aws-sdk-php-laravel Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aws/aws-sdk-php-laravel

0.0 3.0 0.0 96 KB

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

Home Page: http://aws.amazon.com/sdkforphp/

License: Apache License 2.0

Makefile 16.12% PHP 83.88%

aws-sdk-php-laravel's Introduction

AWS Service Provider for Laravel 5

@awsforphp on Twitter Build Status Latest Stable Version Total Downloads ![Gitter](https://badges.gitter.im/Join Chat.svg)

This is a simple Laravel service provider for making it easy to include the official AWS SDK for PHP in your Laravel and Lumen applications.

This README is for version 3.x of the service provider, which is implemented to work with Version 3 of the AWS SDK for PHP and Laravel 5.1.

Major Versions:

  • 3.x (YOU ARE HERE) - For laravel/framework:~5.1 and aws/aws-sdk-php:~3.0
  • 2.x (2.0 branch) - For laravel/framework:5.0.* and aws/aws-sdk-php:~2.4
  • 1.x (1.0 branch) - For laravel/framework:4.* and aws/aws-sdk-php:~2.4

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": "~3.0"
    }
}

Then run a composer update

php composer.phar update

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

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

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

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

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

Configuration

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)

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 [
    'credentials' => [
        'key'    => 'YOUR_AWS_ACCESS_KEY_ID',
        'secret' => 'YOUR_AWS_SECRET_ACCESS_KEY',
    ],
    'region' => 'us-west-2',
    'version' => 'latest',
    
    // You can override settings for specific services
    'Ses' => [
        'region' => 'us-east-1',
    ],
];

Referring Laravel 5.2.0 Upgrade guide, you must using config
 file instead of environment variable option if using php artisan config:cache.

Learn more about configuring the SDK on the SDK's User Guide.

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')->createClient('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::createClient('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

aykutfarsak avatar ben52 avatar caseyh avatar chuck014 avatar cjyclaire avatar daylerees avatar digitalfiz avatar dwightwatson avatar grahamcampbell avatar jasonlewis avatar jeremeamia avatar jeskew avatar josezenem avatar mattzuba avatar nickfan avatar tomasvotruba avatar tomschlick avatar

Watchers

 avatar  avatar  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.