1

I have this code:

<?php
    require('aws/aws-autoloader.php');
    echo "1";
    use Aws\S3\S3Client;
    echo "2";
    $s3Client = S3Client::factory(array(
        'key'    => 'mykey',
        'secret' => 'mysecret',
    ));
    echo "3";
    echo  "OK!";
?>

While on my machine the output is "123OK!" (as expected) after uploading it to the server I get only "12" (meaning the creation of the object fails?)

My local machine is running PHP 5.3.27 while the server is running 5.5.5-1chl1~precise1

Update:

The error I'm getting:

Fatal error: Uncaught exception 'Guzzle\Common\Exception\RuntimeException' with message 'The PHP cURL extension must be installed to use Guzzle.' in /var/www/api/1.0/aws/Guzzle/Http/Client.php:70 Stack trace: #0 /var/www/api/1.0/aws/Aws/Common/Client/AbstractClient.php(78): Guzzle\Http\Client->__construct('https://s3.amaz...', Object(Guzzle\Common\Collection)) #1

How do I install what is needed on a linux on C2?

Uri Agassi
  • 36,848
  • 14
  • 76
  • 93
Doron Goldberg
  • 643
  • 1
  • 9
  • 23
  • 1
    Step one: [Enable error reporting](http://stackoverflow.com/a/6575502/1438393) – Amal Murali Feb 14 '14 at 12:09
  • This is what I get: Fatal error: Uncaught exception 'Guzzle\Common\Exception\RuntimeException' with message 'The PHP cURL extension must be installed to use Guzzle.' in /var/www/api/1.0/aws/Guzzle/Http/Client.php:70 Stack trace: #0 /var/www/api/1.0/aws/Aws/Common/Client/AbstractClient.php(78): Guzzle\Http\Client->__construct('https://s3.amaz...', Object(Guzzle\Common\Collection)) #1 - how do I install it on a linux hosted on amazon? – Doron Goldberg Feb 14 '14 at 13:07

3 Answers3

3
sudo apt-get install php5-curl
sudo service apache2 restart
leecsargent
  • 151
  • 1
  • 1
  • 11
  • 1
    Although this might fix the issue, it would be best to at least add some more comments or explanation to your answer so people could learn and not just copy paste – Jasper Jul 29 '15 at 15:33
  • good point @Jasper. I had simply been running into the same issue and didn't realize that apache needed a restart after installing. So that should work. It worked for me. – leecsargent Jul 30 '15 at 17:23
2

The error message says:

The PHP cURL extension must be installed to use Guzzle.

So… you need to install the PHP cURL extension.

how do I install it on a linux hosted on amazon?

It depends on the OS. Installing in Ubuntu is different from installing in Amazon Linux.

Ryan Parman
  • 6,855
  • 1
  • 29
  • 43
0

How about trying this :

<?php

require('aws/aws-autoloader.php');

use Aws\Common\Aws;

$aws_access_key     =   '';     // AWS Access key
$aws_access_security    =   '';     //  AWS Security Key
$aws_default_region =   'ap-southeast-1';   //  Your Default Region
$aws_default_scema      =   'http';             //  Default Protocol Schema

// Instantiate the AWS client with your AWS credentials
$aws = Aws::factory(array(
    'key'    => $aws_access_key,
    'secret' => $aws_access_security,
    'region' => $aws_default_region,
    'scheme' => $aws_default_scema,
));

// Define S3client Object
$s3Client   =   $aws->get('s3');

// Test

var_dump($s3Client);

?>

That should work. But i think you should use composer method of AWS sdk use.

if you need a guide line or a script to work with s3, you can use my code on github : https://github.com/arizawan/aiss3clientphp

RainWalker
  • 11
  • 2