dev-master
9999999-devA CakePHP component to use the Amazon SDK for PHP
WTFPL
The Requires
A CakePHP component to use the Amazon SDK for PHP
This plugin is a (very) thin veil over Amazon's AWS SDK for PHP for use in CakePHP controllers. Forked from many others but upgraded to support new sdk 2 and removed sdk Vendor from the plugin for a more composer-compatible installation., (*1)
Warning: the new sdk is very different. Old code may no longer work., (*2)
Add to composer, this will also install the Amazon SDK for PHP as a dependency, (*3)
"ali1/cakephp-amazon-aws-sdk": "dev-master"
Add the component to a controller, (*4)
public $components = array('Amazonsdk.Amazon');
You must add configuration to bootstrap.php., (*5)
Configure::write('Amazonsdk.credentials', array( 'key' => 'YOUR KEY', 'secret' => 'YOUR SECRET', 'region' => 'us-east-1' ));
Don't forget to replace the placeholder text with your actual keys!, (*6)
At this point you have access to all of the methods available from the AWS SDK. The following is a small list. The full list can be found at (http://docs.aws.amazon.com/aws-sdk-php/latest/namespace-Aws.html)., (*7)
Not all of the methods for each service has been thoroughly tested. If you run into any issues, feel free to open an issue here, on the repository., (*8)
The specific objects for each service can be accessed through the component as a member of it. Here are some examples:, (*9)
$this->Amazon->Sns
$this->Amazon->CloudFront
$this->Amazon->CloudWatch
$this->Amazon->Ec2
$this->Amazon->ElasticBeanstalk
$this->Amazon->Sqs
Add a job to the SQS queue, (*10)
$this->Amazon->Sqs->sendMessage(array( 'QueueUrl' => Configure::read('SQS.queueUrl'), 'MessageBody' => json_encode(array('jobtype'=>'SendEmails', 'data'=>array('id' => 5))) ));
From a model or shell, (*11)
if (!isset($this->Amazon)) { App::import('Component', 'Amazonsdk.Amazon'); $collection = new ComponentCollection(); $Controller =& new Controller(); $this->Amazon = new AmazonComponent($collection); $this->Amazon->initialize($Controller); } $this->Amazon->Sqs->sendMessage(array( 'QueueUrl' => Configure::read('SQS.queueUrl'), 'MessageBody' => json_encode(array('jobtype'=>'SendEmails', 'data'=>array('id' => 5))) ));
A CakePHP component to use the Amazon SDK for PHP
WTFPL