Reputation: 185
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.
Upvotes: 2
Views: 1205
Reputation: 185
Enabling mbstring extension (multibyte string), as suggested by Chris did the trick!
Upvotes: 6