gpt4 book ai didi

php - 找不到类 'Aws\Common\Aws' cakephp

转载 作者:行者123 更新时间:2023-12-05 07:53:58 24 4
gpt4 key购买 nike

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

I use zip files not any composer.

我遇到以下错误。

Class 'Aws\Common\Aws' not found 

我创建了一个自定义组件来访问 SDK 的所有功能。引用https://github.com/Ali1/cakephp-amazon-aws-sdk

我的文件夹结构如下

enter image description here

这是我的 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;
}
}

我引用这个问题在文件的顶部添加了这两行 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';

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

最佳答案

@urfusion 你能不能把 AWS SDK 文件夹从 app/Plugin 移到 app/Vendor 在 app/Vendor 里面 然后尝试导入 aws-sdk AmazonComponent 具有函数 initialize

我正在使用 AWS PHP SDK V3

//首先处理加载我们的库...

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

关于php - 找不到类 'Aws\Common\Aws' cakephp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32052772/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com