How to reference nested requires in app.yaml for App Engine PHP

馋奶兔 提交于 2019-12-13 04:59:17

问题


I have a index.php with a

require 'myfolder/folder/lib1.php';

So in app.yaml I reference:

- url: /myfolder/folder/lib1.php
  script: myfolder/folder/lib1.php

but this lib1.php does another require 'lib2.php'; at same folder level /myfolder/folder/. So it trows error 500 because it can't find lib2.php. How can I properly reference them both in app.yaml?


回答1:


Your app.yaml file is for routing requests from incoming URLs to the initial script you want to use to process the request.

You don't need to add routings for each and every *.php file that you want to include from one script to another.

For example, look at the app.yaml example for running wordpress. It just has the URLs that clients will access, but not all of the php scripts used by wordpress.




回答2:


The problem you face is most likely independent to Google App Engine. On Google App Engine, the standard rules of PHP file-inclusion still applies. The only potential difference here is that the files are read-only (but that should not pose any problems in your case).

So if lib1.php requires lib2.php you need to require the later before you require the other. That is standard PHP behavior:

require 'myfolder/folder/lib2.php'; 
require 'myfolder/folder/lib1.php';

To learn more what exactly caused the 500 error on Google App Engine, consider downloading the log and look into it. This is also independent to Google App Engine, because that is the best suggestion one can give with any webserver on 500 errors.




回答3:


The error 500 was thrown basically because Google App Engine for php doesn't support CURL extension used in the Facebook php SDK. Nothing related to app.yaml includes. I forked the official fb sdk git and I'm patching a solution right now.



来源:https://stackoverflow.com/questions/16663771/how-to-reference-nested-requires-in-app-yaml-for-app-engine-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!