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

2
  • I have also changed the php.ini file to display all sorts of error (stackoverflow.com/questions/5050426/…), and still nothing (white screen) Commented Nov 5, 2012 at 16:48
  • 1
    Do you have error_reporting on? have you checked your Apache error logs? Commented Nov 5, 2012 at 17:18

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.