-1

I am using Codeigniter.

My project works fine with development environment of Codeigniter, but when I switch to production it shows blank page.

Now I tried to print all the error messages, but it does show any! Even I tried to look at error logs but that also does not show any error or warnings.

I tried to display all errors and warnings so that I can resolve them.

ini_set('display_errors', 1);

In my development environment there are no errors, not even in my linux apache console, but when I switch to production it just shows me blank white page !

How do I debug this ?

My Code :

    define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'production');

/*
 *---------------------------------------------------------------
 * ERROR REPORTING
 *---------------------------------------------------------------
 *
 * Different environments will require different levels of error reporting.
 * By default development will show errors but testing and live will hide them.
 */
switch (ENVIRONMENT)
{
    case 'development':
        error_reporting(-1);
        ini_set('display_errors', 1);
    break;

    case 'testing':
    case 'production':
        ini_set('display_errors', 0);
        if (version_compare(PHP_VERSION, '5.3', '>='))
        {
            error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
        }
        else
        {
            error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
        }
    break;

    default:
        header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
        echo 'The application environment is not set correctly.';
        exit(1); // EXIT_ERROR
}


if (defined('ENVIRONMENT'))
{
    switch (ENVIRONMENT)
    {
        case 'development':
            error_reporting(E_ALL);
        break;

        case 'testing':
        case 'production':
            error_reporting(0);
        break;

        default:
            exit('The application environment is not set correctly.');
    }
}
Rajan
  • 2,427
  • 10
  • 51
  • 111
  • What log files did you check? – revo Dec 04 '18 at 11:49
  • try debugging. start with a print and exit at the index page. if working check the code and files one by one. Also try adding ini_set('display_errors', 1); in the switch case against production environment – Golwin Dec 04 '18 at 12:07
  • is PHP installed in your production server? – Javier Larroulet Dec 04 '18 at 12:29
  • @revo i checked the apache logs and codeigniter default error logs – Rajan Dec 05 '18 at 08:36
  • @CD001 its not a live server, its a local server, but i want test weather eveything is working fine or not, so when i swich to my production environment it shows blank page, for development enivroment it does not display any error or warning, hiow i do i come to know which error to solve to let this work in production enviroment. its not a silly question if you have an answer give it – Rajan Dec 05 '18 at 08:39
  • @Golwin thats exactly what i did, but for Codeigniter framework then this line exectues it stops working : `require_once BASEPATH.'core/CodeIgniter.php';` – Rajan Dec 05 '18 at 08:40
  • @JavierLarroulet yes i have PHP 7.0 installed on centos system – Rajan Dec 05 '18 at 08:40
  • @rajan check https://stackoverflow.com/questions/21128063/codeigniter-incorrect-system-path-on-private-server – Golwin Dec 05 '18 at 09:24
  • @Rajan - since my comment was deleted, I'm not 100% sure what I asked... I **think** *I* was asking a silly question like whether the server had the relevant environment variable (`CI_ENV`) defined as without it you're defaulting to 'production' anyway because of how you define the `ENVIRONMENT` constant - and that being the case `display_errors` is off. I wasn't saying *your* question is silly. – CD001 Dec 05 '18 at 09:41

1 Answers1

0

You need to verify few stuff:

  • server is working fine
  • you are in exactly same directory which is mapped in server
  • type I am here in root -> index.php of codeigniter and see if it prints instead of blank page
  • check .htaccess
Naveed Ramzan
  • 3,565
  • 3
  • 25
  • 30