无法使用PHP在Google App Engine Dev服务器上写入文件?

Gre*_*ina 1 php google-app-engine development-environment file-writing

几个小时前,我确实在工作.不知道我做了什么搞砸了,如果有的话.我试图使用file_put_contents()到我的临时目录中的test.txt文件来测试一些东西.我不能使用print_r()或echo,因为有时它是我正在测试的ajax调用.我一直遇到的错误是:

Warning: file_put_contents(temp/test.txt): The local filesystem is readonly, open failed in sub-dirs.../request.php on line 62

Warning: file_put_contents(temp/test.txt): failed to open stream: No such file or directory in sub-dirs.../request.php on line 62
Run Code Online (Sandbox Code Playgroud)

我不是在制作.这是本地的,根据文档,这应该工作:

在开发Web服务器中存储数据

Google App Engine for PHP支持通过PHP的流API读取和写入Google云端存储.开发人员可以通过将其指定为支持PHPs Streams实现的任何PHP函数的URI(例如fopen(),fwrite()或get_file_contents())来读取和写入Google云存储中的对象.

在开发服务器中,当指定Google云存储URI时,我们通过读取和写入用户本地文件系统上的临时文件来模拟此功能.这些文件在请求之间保留,允许您在将代码部署到App Engine之前测试本地开发环境中的功能.

在PHP开发服务器中,像'fopen()这样的流调用,'gs://'url上的file_get_contents()通过读写本地文件系统来模拟.

我非常沮丧,所以任何帮助都非常感激.将upvote.

小智 6

盯着SDK 1.9.18,dev_appserver默认禁用本地文件写入,以更好地模拟生产环境.您可以通过在php.ini文件中添加"google_app_engine.disable_readonly_filesystem = 1"来启用文件写入.