简体   繁体   中英

Use the AWS phar file in codeigniter

I'm creating a web application, using the Amazon SDK 2.5.2. It uses the modular HMVC approach with codeigniter.

I've successfully used the SDK 1.x up to this point but really want to switch to the newest version.

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 . The last option sounds the best in my situation (apart from Composer which, as I said, is not going to work). I have put the phar in the libraries folder and when requiring it from a normal PHP file and then use ing it:

// 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:

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.

You can only use use in the global scope, or inside a namespace. You cannot declare use inside a class, method, function or anything else.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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