Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up php-sdk-gae with symfony2

I'm trying to run symfony2 with a hello world sample bundle inside php-sdk-gae.

I'm following the instructions provided in https://developers.google.com/appengine/docs/php/ and I can run the demo with the development controller (i.e: configuring app.yaml as following:

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

But when I try to run it with the production controller (app.php instead app_dev.php), I get an internal server error.

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:

$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).

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/

I'm new in GAE, and I wonder Where can I find logs to get some more information about this error.

like image 636
jonaguera Avatar asked May 23 '13 19:05

jonaguera


2 Answers

There is an uncaught exception in your production environment. Thats the reason for the http 500 error.

Let me quickly explain 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.

This covers the first and the third case where you don't get the http 500 error ( caused by an uncaught exception ).

$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.

$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 ( i.e. bash ) or if not available open the file in your editor and look for exceptions at the end.

tail -f app/logs/prod.log 

In the symfony2 standard edition logfiles can be found at

app/logs/%kernel.environment%.log  

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

like image 170
Nicolai Fröhlich Avatar answered Oct 20 '22 12:10

Nicolai Fröhlich


The problem is related with .htaccess file shipped with Symfony 2.2

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

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.

like image 28
jonaguera Avatar answered Oct 20 '22 12:10

jonaguera