GAE PHP应用程序:无法找到包装"gs" [英] GAE PHP application: Unable to find the wrapper "gs"

查看:96
本文介绍了GAE PHP应用程序:无法找到包装"gs"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在按照以下文档在标准 php73 Google App引擎环境中编写一些非常简单的代码:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆