简体   繁体   English

使用symfony2设置php-sdk-gae

[英]Setting up php-sdk-gae with symfony2

I'm trying to run symfony2 with a hello world sample bundle inside php-sdk-gae. 我正在尝试使用php-sdk-gae中的hello world示例包运行symfony2。

I'm following the instructions provided in https://developers.google.com/appengine/docs/php/ and I can run the demo with the development controller (ie: configuring app.yaml as following: 我按照https://developers.google.com/appengine/docs/php/中提供的说明操作,我可以使用开发控制器运行演示(即:配置app.yaml如下:

application: helloworld
version: 1
runtime: php
api_version: 1

handlers:
- url: /bundles
  static_dir: helloWorld/web/bundles

- url: /favicon.ico
  static_files: helloWorld/web/favicon.ico
  upload: helloWorld/web/favicon.ico

- url: /.*
  script: helloWorld/web/app_dev.php

It works fine, and I am able to get a Hello World after running the server and load /hello/World page 它工作正常,我可以在运行服务器和加载/ hello / World页面后获得Hello World

But when I try to run it with the production controller (app.php instead app_dev.php), I get an internal server error. 但是当我尝试使用生产控制器(app.php而不是app_dev.php)运行它时,我收到内部服务器错误。

Request URL:http://mysite.local:8080/hello/World
Request Method:GET
Status Code:500 Internal Server Error

The only clue is in the console window where I launched the server, showing the lines ... 唯一的线索是在我启动服务器的控制台窗口中,显示了行...

ERROR:root:php failure (255) with:
Status: 500 Internal Server Error
X-Powered-By: PHP/5.4.15
Content-type: text/html

If I make some changes in app.php files, I realize that it works fine with following AppKernel loading lines: 如果我在app.php文件中做了一些更改,我意识到它可以正常使用以下AppKernel加载行:

$kernel = new AppKernel('prod', true);
$kernel = new AppKernel('dev', false);
$kernel = new AppKernel('dev', true);

But not with the default configuration for the production enviroment ('prod',false). 但不是生产环境的默认配置('prod',false)。

I'm launching GAE server with this command: google_appengine/dev_appserver.py --php_executable_path=/home/jon/php-sdk-gae/php-5.4.15/installdir/bin/php-cgi helloWorld/ 我正在使用此命令启动GAE服务器:google_appengine / dev_appserver.py --php_executable_path = / home / jon / php-sdk-gae / php-5.4.15 / installdir / bin / php-cgi helloWorld /

I'm new in GAE, and I wonder Where can I find logs to get some more information about this error. 我是GAE的新手,我想知道在哪里可以找到日志来获取有关此错误的更多信息。

There is an uncaught exception in your production environment. 您的生产环境中存在未捕获的异常。 Thats the reason for the http 500 error. 这就是http 500错误的原因。

Let me quickly explain AppKernel::__construct 让我快速解释一下AppKernel :: __ construct

$kernel = new AppKernel($environment, $debug);

The first argument is the environment , the second one is the debug option. 第一个参数是环境,第二个参数是调试选项。

If you set debug to true , symfony will try to catch exceptions and show you a nice stracktrace. 如果将debug设置为true,symfony将尝试捕获异常并向您显示一个很好的stracktrace。

This covers the first and the third case where you don't get the http 500 error ( caused by an uncaught exception ). 这涵盖了第一种和第三种情况,即您没有收到http 500错误(由未捕获的异常引起)。

$kernel = new AppKernel('prod', true);
$kernel = new AppKernel('dev', true);

Now you state the error is NOT thrown in dev environment with debug set to false. 现在,您声明错误不会在dev环境中抛出,并且debug设置为false。

$kernel = new AppKernel('dev', false);

This means in dev environment there is no exception . 这意味着在开发环境中没有例外

Now you have to check the production log file to find out which exception has been thrown. 现在,您必须检查生产日志文件以找出抛出的异常。

Use tail -f to see the live changes made to that file in your shell ( ie bash ) or if not available open the file in your editor and look for exceptions at the end. 使用tail -f查看shell中对该文件所做的实时更改(即bash),如果不可用,则在编辑器中打开文件,最后查找异常。

tail -f app/logs/prod.log 

In the symfony2 standard edition logfiles can be found at 在symfony2标准版中可以找到日志文件

app/logs/%kernel.environment%.log  

... with %kernel.environment% being one of dev/prod/test ...%kernel.environment%是dev / prod / test之一

The problem is related with .htaccess file shipped with Symfony 2.2 该问题与Symfony 2.2附带的.htaccess文件有关

I can use without any problem an application in symfony 2.0, and my application with Symfony 2.2 also works if I replace the web/.htaccess file shipped with Symfony 2.2 with the one shipped with Symfony 2.0 我可以毫无问题地使用symfony 2.0中的应用程序,如果我将Symfony 2.2附带的web / .htaccess文件替换为Symfony 2.0附带的文件,我的Symfony 2.2应用程序也可以使用

Maybe it is something related with the change made in order to avoid duplicate content (/app.php/something and /something), because since Symfony 2.2, /app.php redirects (301) the request. 也许这是为了避免重复内容(/app.php/something和/ something)所做的更改,因为自Symfony 2.2起,/ app.php重定向(301)请求。

I believe the problem is the lack of write support on the filesystem imposed by GAE. 我认为问题是GAE对文件系统缺乏写支持。 Also, symfony seems to rely on tempnam() function that's disabled in versions lower than 1.9.18 which is not public available at the moment I'm writing this. 此外,symfony似乎依赖于tempnam()函数,该函数在低于1.9.18的版本中被禁用,这在我写这篇文章的时候是公开的。

There is also a problem with caching. 缓存也存在问题。

Maybe the problem is this, I've tried in localhost a project with developement version, all right. 也许问题是这个,我已经在localhost中尝试了一个带有开发版本的项目,好吧。 And when it's deployed to GAE it fails. 当它部署到GAE时它失败了。

Maybe that helps. 也许这有帮助。 http://www.ideato.it/planet-ideato/symfony2-su-google-app-engine/ http://www.ideato.it/planet-ideato/symfony2-su-google-app-engine/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM