简体   繁体   English

在Codeigniter中使用AWS Phar文件

[英]Use the AWS phar file in codeigniter

I'm creating a web application, using the Amazon SDK 2.5.2. 我正在使用Amazon SDK 2.5.2创建一个Web应用程序。 It uses the modular HMVC approach with codeigniter. 它使用带有代码点火器的模块化HMVC方法。

I've successfully used the SDK 1.x up to this point but really want to switch to the newest version. 到目前为止,我已经成功使用了SDK 1.x,但我确实想切换到最新版本。

The site says you could install via composer (a complete nightmare in itself; curl doesn't work correctly on the server, running commandline php doesn't either. I've tried everything!), via zip ( After I upload all the files I have no idea what to do next), PEAR (I don't want to go there) and via Phar . 该网站说,您可以通过composer安装(本身就是一个完整的噩梦; curl在服务器上无法正常工作,运行命令行php也不起作用。我已经尝试了所有方法!),通过zip (我上传了所有文件之后我不知道下一步该怎么做), PEAR (我不想去那里)和通过Phar The last option sounds the best in my situation (apart from Composer which, as I said, is not going to work). 在我的情况下,最后一个选项听起来是最好的(除了我所说的Composer不能正常工作)。 I have put the phar in the libraries folder and when requiring it from a normal PHP file and then use ing it: 我已经把pharlibraries文件夹,并从正常需要它时, PHP文件,然后use荷兰国际集团它:

// Get the complete API
require 'aws.phar';
// Use the API
use Aws\Common\Aws;
use Aws\S3\S3Client;

There is no problem. 没有问题。 I get to use all the functions and everything just works. 我可以使用所有功能,并且一切正常。

However, when require ing from a controller or model and then use ing it, codeigniter returns the following error: 但是,当require从控制器或模型中重新use它时,codeigniter返回以下错误:

unexpected 'use' (T_USE)

I think this has to do with the HMVC structure or codeigniter in general, but as there is no real documentation on it I'm hoping there is someone here who knows what to do next. 我认为这通常与HMVC结构或codeigniter有关,但是由于没有真正的文档,我希望这里有人知道下一步该做什么。

You can only use use in the global scope, or inside a namespace. 您只能在全局范围或命名空间内使用use You cannot declare use inside a class, method, function or anything else. 不能在类,方法,函数或其他任何东西中声明use

http://www.php.net/manual/en/language.namespaces.importing.php http://www.php.net/manual/en/language.namespaces.importing.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM