我正在编写一些非常简单的代码standardphp73 Google App 引擎环境,遵循此处的文档:https://cloud.google.com/appengine/docs/standard/php/googlestorage/ https://cloud.google.com/appengine/docs/standard/php/googlestorage/ and https://cloud.google.com/appengine/docs/standard/php/googlestorage/setup https://cloud.google.com/appengine/docs/standard/php/googlestorage/setup
php.ini(根据此场景的文档不需要,但以防万一)
google_app_engine.allow_include_gs_buckets = "#default#"
索引.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 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");
注册包装器。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)