2

Trying to use the AWS SDK for PHP to list buckets, but I keep getting this error after setting up the S3Client like so:

<?php  
require getcwd() . '/aws.phar' /*v3 of the SDK*/;

use Aws\S3\S3Client;
use Aws\Exception\AwsException;

$credentials = new Aws\Credentials\Credentials('I put my', 'credentials here');

$s3 = new Aws\S3\S3Client([
    'region' => 'us-east-1', /*also tried different regions*/
    'version' => '2006-03-01', /*also tried latest*/
    'credentials' => $credentials /*have also tried putting credentials here*/
]);

$s3->listBuckets(); /*still the same error even if I remove this line */ ?>

If I don't fill at least the region, version and credentials options the SDK actually returns an error telling me to fill them. And here is the error that above code returns:

Fatal error: Uncaught Error: Call to undefined function JmesPath\mb_strlen() in phar:///var/www/mail/aws.phar/JmesPath/Lexer.php:343 Stack trace: #0 phar:///var/www/mail/aws.phar/JmesPath/Parser.php(76): JmesPath\Lexer->tokenize() #1 phar:///var/www/mail/aws.phar/JmesPath/AstRuntime.php(42): JmesPath\Parser->parse() #2 phar:///var/www/mail/aws.phar/JmesPath/Env.php(33): JmesPath\AstRuntime->__invoke() #3 phar:///var/www/mail/aws.phar/Aws/Endpoint/PartitionEndpointProvider.php(117): JmesPath\Env::search() #4 phar:///var/www/mail/aws.phar/Aws/Endpoint/PartitionEndpointProvider.php(99): Aws\Endpoint\PartitionEndpointProvider::mergePrefixData() #5 phar:///var/www/mail/aws.phar/Aws/ClientResolver.php(740): Aws\Endpoint\PartitionEndpointProvider::defaultProvider() #6 phar:///var/www/mail/aws.phar/Aws/ClientResolver.php(295): Aws\ClientResolver::_default_endpoint_provider() #7 phar:///var/www/mail/aws.phar/Aws/AwsClient.php(199): Aws\ClientResolver->resolve() #8 phar:///var/www/mail/aws.phar/Aws/S3/S3Client.php(346): Aws\AwsClie in phar:///var/www/mail/aws.phar/JmesPath/Lexer.php on line 343

PHP version is 7.4, and I have the simplexml extension installed, as Amazon says its a requirement. Server is Apache on AWS Lightsail Ubuntu.

1
  • 3
    Make sure that you have multibyte string support enabled for your PHP. Commented Feb 12, 2021 at 22:33

1 Answer 1

6

Enabling mbstring extension (multibyte string), as suggested by Chris did the trick!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.