我正在标准 php73 Google App 引擎环境中编写一些非常简单的代码,遵循此处的文档:https://cloud.google.com/appengine/docs/standard/php/googlestorage/和 https://cloud.google.com/appengine/docs/standard/php/googlestorage/setup
php.ini(根据此场景的文档不需要,但以防万一)
google_app_engine.allow_include_gs_buckets = "#default#"
index.php:
file_put_contents("gs://#default#/hello.txt", "some text");
并从 Google App Engine 收到以下错误
file_put_contents(): Unable to find the wrapper "gs" - did you forget to enable it when you configured PHP?
据我从文档中看到,应该不需要其他配置,因为 GAE 会在其环境中自动注册文件流包装器。
我错过了什么?谢谢!
最佳答案
事实证明,该文档适用于 PHP 5 环境,而不是 PHP 7(尽管没有说明)。在 PHP 7 中实现此功能的方法记录如下:
https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/appengine/php72/storage/src
我刚刚这样做了:
use Google\Cloud\Storage\StorageClient;
function register_stream_wrapper($projectId) {
$client = new StorageClient(['projectId' => $projectId]);
$client->registerStreamWrapper();
}
register_stream_wrapper("projectId");
注册包装器。
关于php - GAE PHP 应用程序 : Unable to find the wrapper "gs",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56563982/