我在ubuntu 16.04上运行php5.6。我正试图按照aws的步骤将文件上传到s3存储桶中。当运行代码时,我得到了这个错误:
PHP Fatal error: Class 'SimpleXMLElement' not found in .../vendor/aws/aws-sdk-php/src/Api/Parser/PayloadParserTrait.php on line 44
PHP Stack trace:
PHP 1. {main}() .../upload_to_s3.php:0
PHP 2. upload_to_s3() .../upload_to_s3.php:75
PHP 3. AwsS3S3Client->putObject() .../upload_to_s3.php:66
PHP 4. AwsAwsClient->__call() .../upload_to_s3.php:66
PHP 5. AwsAwsClient->execute() .../vendor/aws/aws-sdk-php/src/AwsClientTrait.php:86
PHP 6. GuzzleHttpPromisePromise->wait() .../vendor/aws/aws-sdk-php/src/AwsClientTrait.php:58
PHP 7. GuzzleHttpPromisePromise->waitIfPending() .../vendor/guzzlehttp/promises/src/Promise.php:62
PHP 8. GuzzleHttpPromisePromise->invokeWaitList() .../vendor/guzzlehttp/promises/src/Promise.php:226
PHP 9. GuzzleHttpPromisePromise->waitIfPending() .../vendor/guzzlehttp/promises/src/Promise.php:269
PHP 10. GuzzleHttpPromisePromise->invokeWaitList() .../vendor/guzzlehttp/promises/src/Promise.php:226
PHP 11. GuzzleHttpPromisePromise->waitIfPending() .../vendor/guzzlehttp/promises/src/Promise.php:269
PHP 12. GuzzleHttpPromisePromise->invokeWaitFn() .../vendor/guzzlehttp/promises/src/Promise.php:224
PHP 13. GuzzleHttpHandlerCurlMultiHandler->execute() .../vendor/guzzlehttp/promises/src/Promise.php:248
PHP 14. GuzzleHttpHandlerCurlMultiHandler->tick() .../vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php:145
PHP 15. GuzzleHttpPromiseTaskQueue->run() .../vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php:118
PHP 16. GuzzleHttpPromiseRejectedPromise::GuzzleHttpPromise{closure}() .../vendor/guzzlehttp/promises/src/TaskQueue.php:48
PHP 17. GuzzleHttpPromisePromise::GuzzleHttpPromise{closure}() .../vendor/guzzlehttp/promises/src/RejectedPromise.php:42
PHP 18. GuzzleHttpPromisePromise::callHandler() .../vendor/guzzlehttp/promises/src/Promise.php:169
PHP 19. AwsWrappedHttpHandler->Aws{closure}() .../vendor/guzzlehttp/promises/src/Promise.php:204
PHP 20. AwsWrappedHttpHandler->parseError() .../vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php:101
PHP 21. call_user_func:{.../vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php:178}() .../vendor/aws/aw s-sdk-php/src/WrappedHttpHandler.php:178
PHP 22. AwsApiErrorParserXmlErrorParser->__invoke() .../vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php:178
PHP 23. AwsApiErrorParserXmlErrorParser->parseXml() .../vendor/aws/aws-sdk-php/src/Api/ErrorParser/XmlErrorParser.php:42
我已经尝试安装php-xml并得到这个:
php-xml is already the newest version (1:7.1+55+ubuntu16.04.1+deb.sury.org+1)
尝试安装特定版本,即apt-install php5.6-xml找不到包,并且可用的mods中缺少simplexml.conf文件。
我在/etc/php/7.0/mods-available中有一个simplexml.ini,并尝试切换到php7.0来尝试纠正这些问题,但没有成功。
如有任何帮助,我们将不胜感激。
发现我的问题是我的aws用户密钥。我用错了钥匙,它不断地抛出这个错误。如果有人遇到同样的问题,请仔细检查你的钥匙,希望你能省去头疼的事。无需安装任何扩展即可使其正常工作。