[英]How to use Amazon s3 as a Codeigniter library?
I created a file called awslib.php
and put it in the application/libraries
folder. 我创建了一个名为
awslib.php
的文件并将其放在application/libraries
文件夹中。 These are the contents of awslib.php: 这些是awslib.php的内容:
<?php
class Awslib {
function Awslib()
{
require_once('sdk-1.5.6.2/sdk.class.php');
}
}
Also in the libraries folder is the PHP sdk as a folder named sdk-1.5.6.2
. 在libraries文件夹中,PHP sdk也是名为
sdk-1.5.6.2
的文件夹。
On my home controller I am loading the library and instantiating the s3 class: 在我的家庭控制器上,我正在加载库并实例化s3类:
$this->load->library('awslib');
$s3 = new AmazonS3();
When I load my homepage I get this error: 当我加载我的主页时,我收到此错误:
Fatal error: Class 'AmazonS3' not found in /var/www/application/controllers/home.php on line 23
Why isn't it working? 为什么不工作?
Note: the problem isn't with s3, I can get it to work fine when I store it outside codeigniter and load the demo files that come with the sdk. 注意:问题不在于s3,当我将它存储在codeigniter之外并加载sdk附带的演示文件时,我可以正常工作。
I'm assuming you're using the SDK for PHP directly. 我假设您直接使用SDK for PHP 。 Most SDKs don't play nicely in CI unless wrapped up.
除非结束,否则大多数SDK在CI中都不能很好地发挥作用。
I highly recommend using the amazon-s3 library (or rather, the spark ). 我强烈推荐使用amazon-s3 库 (或者更确切地说, 火花 )。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.