Welcome Guest, Not a member yet? Register   Sign In
PHP errors not showing in testing environment
#1

[eluser]Unknown[/eluser]
Hello,

I run into a weird problem where I cannot figure the answer for. I have searched Google and so on but there does not seem to be a solid answer. I am running a CentOS server with apache and so on and php is normally logging into a /var/log/phperrors.log file.

Now I have altered index.php as follows:

Code:
switch (ENVIRONMENT)
{
  case 'development':
  
   error_reporting(E_ALL);
  
   $system_path  = 'cut';
   $application_folder = 'cut';
  
  break;
  
  case 'testing':
  
   error_reporting(E_ALL);
  
   $system_path  = 'cut';
   $application_folder = 'cut';
  
  break;
  
  case 'production':
  
   error_reporting(0);
  
  break;

  default:
   exit('The application environment is not set correctly.');
}

So in my opinion one would expect for php errors to popup on screen when the environment is set to both development and testing. I would certainly like to have it this way since development is on my local machine, testing is on a replica machine of the production server and eventually the production server is on its own.

When I set my environment on the testing server to "development" all goes well, I get errors popping up However when I switch the environment to testing all errors disapear and I am just left with a blank screen. Also the errors do not get logged to my general php error log which is set server wide.

Can anyone tell me if this is a bug or if I am missing something in the picture here.

Thanks!
#2

[eluser]Aken[/eluser]
How are you setting your environment constant? Are you sure it is being set properly, not overwritten, etc?

You could try combining the cases, also. I don't see why that would make a difference, but it'll clean up your code.

Code:
case 'development':
case 'testing':
    error_reporting(E_ALL);
    //..
    break;
#3

[eluser]Unknown[/eluser]
Aken,

Thanks for pointing me in the overwritten direction. I was really breaking my head on this one 2 nights ago.
Now when having a fresh look and your pointer on the overwritten part I noticed that indeed the error_reporting got overwritten somewhere.

I have removed that and now it works like a charm.

About the code cleaning, this is indeed something I have todo still but I was getting nuts on this "problem". Now thats solved I can focus again on producing clean code Smile

Thanks a lot.




Theme © iAndrew 2016 - Forum software by © MyBB