Jump to content

Getting Amazon AWS SDK to work with PW


artaylor
 Share

Recommended Posts

Hi all,

I am trying to use Amazon S3 to store video files for a client. I am having trouble getting the SDK to work. I am sure it is a stupid error on my part but my head is sore from banging it against my desk and I thought I would finally ask for some help. 

I am running PW 3.0.11 on NGINX.

1. Amazon recommends using Composer to install the SDK. I was not sure where in the path to install the SDK so I put composer in the /site folder and installed the SDK there (putting vendor at the same level as modules), then I put the require and uses statements in _init.php. I always got an error saying it could not load the aws or s3 classes from the library.

2. So, then I tried to use aws.phar. I put that in the /site directory but once again, no matter what I do, it will not load with the following error:

require(): Failed opening required '/site/aws.phar'

The file is there with proper permissions and the code for loading is:

// --- amazon S3 stuff
require $config->urls->site . 'aws.phar';

$s3 = new Aws\S3\S3Client([
    'version' => 'latest',
    'region'  => 'us-standard',
  ]);

So, here are my questions:

1. In general, where is the correct place to put a php library? It is not a PW module so I assume it should not go in the modules folder.

2. Should I use Composer to install the SDK? If so, where do I put the files? Should I add the AWS SDK to the main composer.json file or put it somewhere else?

3. If I don't use Composer, where do I put the aws.phar file so that PW can load it?

4. Should I not put the 'require' in the _init.php file and move it to another file (_func.php)?

I am sure there is a massive face-palm in my future when this gets sorted out.

Thanks

Link to comment
Share on other sites

Newest update after trying @LostKobrakai's suggestions:

1. Used Composer in root of site. AWS is in the vendor folder.

2. 3.0.11 index.php file calls the composer autoloader so I did not add the require 'vendor/autoloader.php' to the config.php file.

3. Tried to create an S3 object in _init.php using the following:

$s3 = new Aws\S3\S3Client([
    'version' => 'latest',
    'region'  => 'us-standard',
  ]);

but get the following error:

Class 'ProcessWire\Aws\S3\S3Client' not found

The code not sure why it is trying to reference Processwire\Aws...

Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...