PHP AWS SDK 创建 S3Client 时出现致命错误
PHP AWS SDK Fatal error creating S3Client
尝试使用 PHP 的 AWS SDK 列出存储桶,但在设置 S3Client 后我一直收到此错误:
<?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 */ ?>
如果我至少没有填写区域、版本和凭据选项,SDK 实际上会 returns 提示我填写它们。
这是上面代码 returns:
的错误
致命错误:未捕获错误:调用 phar:///var/www/mail/aws.phar/JmesPath/Lexer.php:343 中的未定义函数 JmesPath\mb_strlen() 堆栈跟踪:# 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 第 343 行
PHP 版本是 7.4,我安装了 simplexml 扩展,亚马逊说这是一个要求。
服务器是 AWS Lightsail 上的 Apache Ubuntu.
按照 Chris 的建议启用 mbstring 扩展(多字节字符串)!
尝试使用 PHP 的 AWS SDK 列出存储桶,但在设置 S3Client 后我一直收到此错误:
<?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 */ ?>
如果我至少没有填写区域、版本和凭据选项,SDK 实际上会 returns 提示我填写它们。 这是上面代码 returns:
的错误致命错误:未捕获错误:调用 phar:///var/www/mail/aws.phar/JmesPath/Lexer.php:343 中的未定义函数 JmesPath\mb_strlen() 堆栈跟踪:# 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 第 343 行
PHP 版本是 7.4,我安装了 simplexml 扩展,亚马逊说这是一个要求。 服务器是 AWS Lightsail 上的 Apache Ubuntu.
按照 Chris 的建议启用 mbstring 扩展(多字节字符串)!