Giter VIP home page Giter VIP logo

yiiaws's Introduction

Yii-AWS

Provides a simple way to configure and use Amazon AWS SDK PHP 2. For more information regarding its services, please go to http://docs.aws.amazon.com/aws-sdk-php-2/latest/namespace-Aws.html.

Before you start

The wrapper is in alpha version. Obviously, I couldn't test all the possibilities of Amazon SDK, I have tested just a couple. But being just a wrapper, it should not have any issues whatsoever but those related to the SDK itself.

I published, in order to get good feedback from you guys and again, provide another utility to the Yii framework. If you wish to collaborate, comment, whatever, please, do not hesitate to add your two cents via its github repository. Everybody welcome.

Overview

The main purpose of this extension was to be able to configure the sdk in a very easy way, and then be able to make use of its classes with an easy and configurable import at my main config file.

Install

I assume that if you wish to use this extension, you already have your AWS credentials.

Since schmunk convinced me about composer wonders. From now on, you will be able to install my extensions using composer (https://packagist.org/packages/2amigos/).

Via Composer

  • Add 2amigos/yii-aws as a dependency in your project's composer.json file.
	{
   		"require": {
      		"2amigos/yii-aws": "dev-master"
   		}
	}
  • Download and install Composer.
curl -s "http://getcomposer.org/installer" | php
  • Install your dependencies.
php composer.phar install
  • Require Composer's autoloader. Composer also prepares an autoload file that's capable of autoloading all of the classes in any of the libraries that it downloads. To use it, just add the following line to your code's bootstrap process.
require '/path/to/vendor/autoload.php';

You can find out more on how to install Composer, configure autoloading, and other best-practices for defining dependencies at getcomposer.org.

The Old Fashion Way

If you do not work with composer, then simply download or clone from its repository and place it wherever you wish.

After you do that, make sure you import on your main.php config file, the classes within the yii-aws/components/* folder.

Configuration

The library has a config folder where you will find a file named "aws-config" to setup the configuration options for the services. For more information about configuring your services, please have a look at http://docs.aws.amazon.com/awssdkdocsphp2/latest/gettingstartedguide/sdk-php2-using-the-sdk.html

Note do not forget to add your AWS credentials there :)

###How to use it

// This import is better to be included in your main
// config file. For those newbies to the framework, 
// please recall that this is a path alias, you should 
// write exactly where it is
Yii::import('path.to.amazon.components.*');

$s3 = new A2S3();
$response = $s3->listBuckets(); // we are going to list the buckets

// just for the sake of the example
print_r($response);

$result = $s3->putObject(array(
    'Bucket' => 'YOUR-BUCKET,
    'Key'    => 'data.txt',
    'Body'   => 'Hello!'
));

// Fancier options (such as waiters - http://docs.aws.amazon.com/aws-sdk-php-2/guide/latest/feature-waiters.html)
// require calling the S3 getClient() method.  If you don't use the getClient() method, you will get an error
// something like "Command was not found matching WaitUntilObjectExists"
$s3->getClient()->waitUntilObjectExists(array(
    'Bucket' => 'YOUR-BUCKET',
    'Key'    => 'data.txt',
));

###Requirements

###Resources

2amigOS!
web development has never been so fun
www.2amigos.us

yiiaws's People

Contributors

acorncom avatar jordigg avatar zmilan avatar

Watchers

James Cloos avatar  avatar Alexander Roussakov avatar Liran Keren avatar  avatar  avatar  avatar  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.