2

I am using AWS Elastic Beanstalk for PHP which manage 1 EC2 linux server with Apache web server.

When deploying a different version (zip file with all my php scripts) through the management console i sometimes run into a weird situation.

In some cases, even if i am deploying a version with exactly the same scripts which all worked before, some of them suddenly aren't working. When deploying another version again (still same scripts, same content), suddenly everything is working as normal.

Example of a problematic service :

<?php
// dynamically loads needed classes
    function __autoload($class_name) {
        include $class_name . '.php';
    }
    $response = new Response();

    $response->data = array('platform_version' => Configuration::PLATFORM_VERSION);
    die(json_encode($response));
?>

Normally, this script returns a json object. After changing nothing and deploying a version this scripts returns nothing. Is there a way to find if an error occurred?

BTW, i can see a call to the service in the application_access_log of Apache with return status 200.

EDIT: After changing the error level on the web server i started to see interesting information in the application_error_log :

*[Mon Nov 05 17:19:44 2012] [error] [client 10.210.159.209] PHP Fatal error: require_once() [function.require-once]: Cannot redeclare class response in /var/www/html/InstallerLog.php on line 12 [Mon Nov 05 17:19:44 2012] [error] [client 10.210.159.209] PHP Stack trace: [Mon Nov 05 17:19:44 2012] [error] [client 10.210.159.209] PHP 1. {main}() /var/www/html/InstallerLog.php:0*

Why am i getting this error? I am using :

require_once 'Response.php';

In my script so this kind of error should not occur for my knowledge...

nitzan
  • 319
  • 1
  • 14
  • I have also changed the php.ini file to display all sorts of error (http://stackoverflow.com/questions/5050426/php-errors-not-being-displayed-in-the-browser-ubuntu-10-10), and still nothing (white screen) – nitzan Nov 05 '12 at 16:48
  • 1
    Do you have error_reporting on? have you checked your Apache error logs? – Mike Brant Nov 05 '12 at 17:18

1 Answers1

3

OK. So eventually it was pretty basic.

The error occurred because the class name i was using, "Response", was already in use in other place (not in my code, maybe in the SDK or something like that). After changing the name to something less generic the error didn't happen again. Just for play safe i have also added :

if(!class_exists('MyNewResponse'))

before creating the class.

nitzan
  • 319
  • 1
  • 14