Class 'Aws \ Common \ Aws' not found cakephp

I am using AWS PHP SDK V2.8 in my cakephp. I am working on an AWS ec2 ubuntu machine.

I use zip files, not some composer.

I get the following error.

Class 'Aws\Common\Aws' not found 

I am creating a custom component to access all the features of the SDK. with the link https://github.com/Ali1/cakephp-amazon-aws-sdk

My folder structure is as follows

enter image description here

Here is my AmazonComponent.php

 <?php App::uses('Component', 'Controller'); use Aws\Common\Aws; /** * AmazonComponent * * Provides an entry point into the Amazon SDK. */ class AmazonComponent extends Component { /** * Constructor * saves the controller reference for later use * @param ComponentCollection $collection A ComponentCollection this component can use to lazy load its components * @param array $settings Array of configuration settings. */ public function __construct(ComponentCollection $collection, $settings = array()) { $this->_controller = $collection->getController(); parent::__construct($collection, $settings); } /** * Initialization method. Triggered before the controller `beforeFilfer` * method but after the model instantiation. * * @param Controller $controller * @param array $settings * @return null * @access public */ public function initialize(Controller $controller) { // Handle loading our library firstly... $this->Aws = Aws::factory(Configure::read('Amazonsdk.credentials')); } /** * PHP magic method for satisfying requests for undefined variables. We * will attempt to determine the service that the user is requesting and * start it up for them. * * @var string $variable * @return mixed * @access public */ public function __get($variable) { $this->$variable = $this->Aws->get($variable); return $this->$variable; } } 

I am adding these two lines at the top of the file with a link to this question. How do I load the AWS SDK in CakePHP?

 ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'). PATH_SEPARATOR . ROOT .DS . 'app/Plugin/Amazonsdk/Vendor/aws'); require ROOT . DS . 'app/Plugin/Amazonsdk/Vendor/aws/aws-autoloader.php'; 

Where am I mistaken and how can I fix this?

+1
source share
1 answer

@urfusion Could you move the AWS SDK folder from app/Plugin to app/Vendor in the side of the application / provider. Then try importing aws-sdk AmazonComponent with the initialize function.

I am using AWS PHP SDK V3

// Download our library first ...

  App::import('Vendor','aws-autoloader',array('file'=>'aws'.DS.'aws-autoloader.php')); 
0
source

All Articles