Я создаю плагин S3 для своего приложения. В app/Plugin/S3/Controller/Component/S3Component.php
у меня есть это:
<?php
App::import('Vendor', 'aws/aws-autoloader');
use Aws\S3\S3Client;
class S3Component extends Component {
public function loadS3 () {
$s3 = S3Client::factory(array(
'key' => '',
'secret' => ''
));
return $s3;
}
}
В контроллере моего приложения я вызываю его с помощью $s3 = $this->S3->loadS3();
Выдает ошибку Error: Class 'Aws\S3\S3Client' not found
Я попытался добавить строку: App::uses('Vendor', 'aws/Aws/S3/S3Client');
в класс компонента и удалил use Aws\S3\S3Client;
. Он показывает Error: Class 'S3Client' not found
AWS SDK находится в папке app/Plugin/S3/Vendor/aws
Я загружаю объект S3 со ссылкой на: http://docs.aws.amazon.com/aws-sdk-php/guide/latest/quick-start.html#factory-method
Решение:
Вот так теперь выглядит мой компонент с помощью @akirk.
<?php
ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'). PATH_SEPARATOR . ROOT .DS . 'app/Plugin/S3/Vendor/aws');
require ROOT . DS . 'app/Plugin/S3/Vendor/aws/aws-autoloader.php';
use Aws\S3\S3Client;
class S3Component extends Component {
public function loadS3 () {
$s3 = S3Client::factory(array(
'key' => '',
'secret' => ''
));
return $s3;
}
}
ini_set
иrequire
. - person resting   schedule 18.08.2015