Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error on instantiating class extended from AwsClient subclass

I'm extending my custom Sqs class like this:

class Sqs extends SqsClient
{
    public function __construct()
    {
        parent::__construct(array(
            'credentials' => array(
                'key' => $_ENV['AWS_ACCESS_KEY_ID'],
                'secret' => $_ENV['AWS_SECRET_ACCESS_KEY'],
            ),
            'region' => 'us-west-1',
            'version' => 'latest'
        ));
    }
}

And then I instantiate and use it like this:

$sqs = new Sqs();
$sqs->sendMessage([
    'QueueUrl' => $_ENV['AWS_SQS_URL_PREFIX'] . '/' . $_ENV['AWS_SQS_READER_USER_CREATE'],
    'MessageBody' => $user_json,
    'MessageGroupId' => 1,
    'MessageDeduplicationId' => uniqid(),
]);

But I'm getting a weird error:

The service \"\" is not provided by the AWS SDK for PHP.
like image 268
Sam Malayek Avatar asked Oct 16 '25 12:10

Sam Malayek


1 Answers

The AWS APIs use reflection to figure out what AWS service they're connecting to based on the class name. If that's the case you might try calling your class SqsClient, eg

use Aws\Sqs\SqsClient as BaseSqsClient;

class SqsClient extends BaseSqsClient 
{
     //...
}
like image 143
Jonathon Sim Avatar answered Oct 18 '25 00:10

Jonathon Sim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!