Ich erstelle ein S3-Plugin für meine App. In app/Plugin/S3/Controller/Component/S3Component.php
habe ich diese:Wie lädt man AWS SDK in CakePHP?
<?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;
}
}
In meiner App-Controller, nenne ich es mit $s3 = $this->S3->loadS3();
er den Fehler Error: Class 'Aws\S3\S3Client' not found
ich die Zeile hinzufügen versucht wirft: App::uses('Vendor', 'aws/Aws/S3/S3Client');
auf die Komponentenklasse, und entfernt use Aws\S3\S3Client;
. Es zeigt Error: Class 'S3Client' not found
Das AWS SDK in im Ordner app/Plugin/S3/Vendor/aws
ich anhand der S3-Objekt bin Laden zu: http://docs.aws.amazon.com/aws-sdk-php/guide/latest/quick-start.html#factory-method
Lösung:
Dies ist, wie meine Komponente aussieht jetzt mit Hilfe von @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;
}
}
Danke! Das ist, was ich suche :) – decodingpanda
Ich bin mit dem gleichen Problem konfrontiert. obige Lösung funktioniert nicht für mich .. Ich verwende die gleiche Ordnerstruktur. und folgte https://github.com/Ali1/cakephp-amazon-aws-sdk können Sie mir sagen, ist es richtig oder nicht? – urfusion
Es ist Versionsproblem .. Ich verwende SDK V3 – urfusion