Google App Engine php include / require指令

时间:2013-11-19 12:14:17

标签: php google-app-engine

Google App Engine php include / require指令问题。

文件1:app.yaml

application: myapp

version: 1

runtime: php

api_version: 1

handlers:

- url: /stylesheets

  static_dir: stylesheets

- url: /images

  static_dir: images

- url: /myIncludes

  script: form.php

- url: /.*

  script: HelloWorld.html.php

文件2:php.ini

; This is a simple php.ini file.

; It indicates my desire to use php’s include and require directives.

google_app_engine.allow_include_gs_buckets=‘bucket1’

文件3:form.php

The php code in this file simply echoes an html form.

文件4:HelloWorld.html.php

    <?php

    echo '

        <html>

        <head>

        <style type="text/css">

        body {background-color:red;}

        </style>

        </head><body>

        <table>

        <tr>

        <td>My First Cloud App</td>

        </tr></table>

        ';


        include 'gs://bucket1/form.php';


        echo '

    </body>

    </html>

    ';

?>

Google云端存储中我的存储桶名称为bucket1。 bucket1包含form.php。对于每个人,桶及其对象的所有权限都已设置为读取。 我可以使用所有适当的 PHP 文件函数。但是,我无法使用php指令include require

当我运行myapp时,它会显示带有红色背景的My First Cloud App,但它不会在“form.php”中显示html。我的Google帐户日志文件中出现以下错误:

2013-11-19 01:44:20.209
PHP Warning:  include(gs://bucket1/form.php): failed to open stream: "\google\appengine\ext\cloud_storage_streams\CloudStorageStreamWrapper::stream_open" call failed in /base/data/home/apps/s~myapp/1.335363258528205/HelloWorld.html.php on line 74
W 2013-11-19 01:44:20.209
PHP Warning:  include(): Failed opening 'gs://bucket1/form.php' for inclusion (include_path='.;/base/data/home/apps/s~myapp/1.335363258528205/;/base/data/home/runtimes/php/sdk') in /base/data/home/apps/s~myapp/1.335363258528205/HelloWorld.html.php on line 74

我做错了什么?

2 个答案:

答案 0 :(得分:1)

无需在存储桶中上传form.php ...

无论你创建了多少目录,你仍然不需要为它做斗...... 看,让我给你一个例子......

您的form.php位于/form.php

并且您希望将其包含在/folder1/file1.php中 然后在file1.php中你可以写include('../form.php');

并且您希望将其包含在/folder2/file2.php中 然后在file2.php中你可以写include('../form.php');

如果你自己有根文件中的文件/helloworld.html.php 然后简单写include('form.php');

答案 1 :(得分:0)

Cyber​​Boy是正确的,您不需要将form.php放在GCS存储桶中以包含它。我不确定你所指的文档的哪一部分,但是你想要直接从GCS包含PHP脚本的确有很少和具体的原因。