I'm trying to read messages from my SQS but I can't get that far as I'm having trouble installing the PHP SDK.
I followed the instructions and installed via composer.
My code for testing purposes is:
require 'vendor/autoload.php';
$sqs_credentials = array(
'region' => 'us-west-2',
'version' => 'latest',
'credentials' => array(
'key' => '*****',
'secret' => '**********',
)
);
$sqs_client = new SqsClient($sqs_credentials);
This simply results in
Class 'SqsClient' not found in /var/www/html/sqs_test.php on line 10
I then tried by downloading the zip file directly and used
require 'aws/aws-autoloader.php';
This resulted in the exact same error. What am I doing wrong? I'm quite certain the path is accurate as I can output text directly on Sqs/SqsClient.php.
Still not sure why the above didn't work, but if anyone is trying, this does work:
require 'vendor/autoload.php';
use Aws\Sqs\SqsClient;
$client = SqsClient::factory(array(
'region' => 'us-west-2',
'version' => 'latest',
'credentials' => array(
'key' => '********',
'secret' => '********',
)
)
);
$result = $client->receiveMessage(array(
'QueueUrl' => $sqs_url
));
print_r($result);