GAE PHP应用程序:无法找到包装"gs" [英] GAE PHP application: Unable to find the wrapper "gs"
问题描述
我正在按照以下文档在标准 php73 Google App引擎环境中编写一些非常简单的代码: 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");
注册包装器.
I am writing some very simple code in the standard php73 Google App engine environment, following the documentation here: https://cloud.google.com/appengine/docs/standard/php/googlestorage/ and https://cloud.google.com/appengine/docs/standard/php/googlestorage/setup
php.ini (not required according to docs for this scenario, but just in case)
google_app_engine.allow_include_gs_buckets = "#default#"
index.php:
file_put_contents("gs://#default#/hello.txt", "some text");
and getting the following error from Google App Engine
file_put_contents(): Unable to find the wrapper "gs" - did you forget to enable it when you configured PHP?
As far as I can see from the documentation there should be no other configuration required, as GAE registers the file stream wrapper automatically in their environment.
What am I missing? Thanks!
So it turns out the documentation is for the PHP 5 environment not PHP 7 (though that's not stated). The way to get this working in PHP 7 is documented here:
https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/appengine/php72/storage/src
I just did this:
use Google\Cloud\Storage\StorageClient;
function register_stream_wrapper($projectId) {
$client = new StorageClient(['projectId' => $projectId]);
$client->registerStreamWrapper();
}
register_stream_wrapper("projectId");
to register the wrapper.
这篇关于GAE PHP应用程序:无法找到包装"gs"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!