找不到类“ Aws\Common\Aws” cakephp [英] Class 'Aws\Common\Aws' not found cakephp

查看:120
本文介绍了找不到类“ Aws\Common\Aws” cakephp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在cakephp中使用的是AWS PHP SDK V2.8。我正在AWS ec2 ubuntu计算机上工作。


我不使用zip文件,也不使用任何作曲家。




我遇到以下错误。

  Class'Aws\Common\找不到Aws 

我创建了一个自定义组件来访问SDK的所有功能。并引用



这是我的AmazonComponent.php

 < php 

App :: uses('Component','Controller');
使用Aws\Common\Aws;

/ **
* AmazonComponent
*
*提供进入Amazon SDK的入口点。
* /
类AmazonComponent扩展了组件{

/ **
*构造函数
*保存控制器引用以供以后使用
* @ param ComponentCollection $ collection该组件可以用来延迟加载其组件的ComponentCollection
* @param array $ settings配置设置的数组。
* /
公共函数__construct(ComponentCollection $ collection,$ settings = array()){
$ this-> _controller = $ collection-> getController();
parent :: __ construct($ collection,$ settings);
}

/ **
*初始化方法。在控制器的 beforeFilfer
*方法之前但在模型实例化之后触发。
*
* @param控制器$ controller
* @param array $ settings
* @return null
* @access public
* /
公共函数initialize(Controller $ controller){
//首先处理加载我们的库...
$ this-> Aws = Aws :: factory(Configure :: read('Amazonsdk.credentials' ));
}

/ **
* PHP魔术方法,用于满足对未定义变量的请求。我们
*将尝试确定用户所请求的服务,然后
*为他们启动服务。
*
* @var字符串$ variable
* @return Mixed
* @access public
* /
public function __get($ variable){
$ this-> $ variable = $ this-> Aws-> get($ variable);
返回$ this-> $ variable;
}
}

我将这两行添加到文件顶部该问题的参考
如何将AWS开发工具包加载到CakePHP中? / a>

  ini_set('include_path',ROOT。DS .'lib'。PATH_SEPARATOR。ini_get('include_path')。 PATH_SEPARATOR。ROOT .DS。'app / Plugin / Amazonsdk / Vendor / aws'); 

需要ROOT。 DS。 ‘app / Plugin / Amazonsdk / Vendor / aws / aws-autoloader.php’;

哪里错了,我该如何解决?

@urfusion您能否将AWS开发工具包文件夹从 app / Plugin 移到 app /供应商在应用程序/供应商旁边,然后尝试导入具有函数初始化 AmazonComponent c>。



我正在使用AWS PHP SDK V3



//首先处理加载库...

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


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

I use zip files not any composer.

I am getting following error.

Class 'Aws\Common\Aws' not found 

I create a custom component for accessing all features of SDK. with the reference of https://github.com/Ali1/cakephp-amazon-aws-sdk

My folder structure is as follows

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's `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 add these two line on the top on file with the reference of this question How to load AWS SDK into 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 I am wrong and how can I fix that?

解决方案

@urfusion Could you pls move AWS SDK folder from app/Plugin to app/Vendor In Side the app/Vendor And then try to import aws-sdk AmazonComponent having Function initialize.

I am using AWS PHP SDK V3

// Handle loading our library firstly...

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

这篇关于找不到类“ Aws\Common\Aws” cakephp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆