14

I had a line - $autoload['libraries'] = array('database');, in CI's autoload.php. Because of this I was getting a blank page. When I removed the 'database', option then I started getting the output.

Now my question is not how to configure the database, but how to configure CI to speak its mind. When 'database' was enabled all I got was a complete blank page. No error in php log, no error in Apache log, no error in CI log. In PHP I have set E_ALL. In my CI config I have set log_threshold to 4, i.e. all messages should be logged. What more do I need to do?

AppleGrew
  • 9,302
  • 24
  • 80
  • 124
  • Could you give the output of `phpinfo()` inside of your CI-Program? What does `trigger_error('test', E_USER_NOTICE)` give you? – Lars Sep 10 '11 at 08:17
  • @Lars Can you please let me know the exact section of phpinfo you want since, it outputs a really long list which I think cannot be posted here. BTW the output the `tigger_error` is `A PHP Error was encountered, Severity: User Notice, Message: test, Filename: controllers/welcome.php, Line Number: 22`. This came up in the browser window. In CI logs too it was logged as `ERROR - 2011-09-10 13:49:21 --> Severity: User Notice --> test C:\....\lib\codeigniter\application\aceinvite\controllers\welcome.php 22`. – AppleGrew Sep 10 '11 at 08:22
  • I just wanted to make sure, that the error-settings are correct (which is proven by the trigger_error). It may be possible, that the autoloader does not throw any error messages or exceptions. You could still get lucky defining your own error handler, but I guess it will not help. Maybe someone else has an idea (beside debugging the autoload.php that is) - good luck! :) – Lars Sep 10 '11 at 11:59
  • This helped me, try it: http://stackoverflow.com/questions/9587413/codeigniter-displays-a-blank-page-instead-of-error-messages – admirm Feb 06 '13 at 18:12
  • I found this solution: http://stackoverflow.com/questions/9587413/codeigniter-displays-a-blank-page-instead-of-error-messages It worked for me. – admirm Feb 06 '13 at 18:15

4 Answers4

16

It depends on your version of CI. For < 2.x edit the top level index.php and adjust the error_reporting function to use E_ALL"

error_reporting(E_ALL);

For >= 2.x edit the top level index.php and make sure ENVIRONMENT is set as:

define('ENVIRONMENT', 'development');

which sets the error_reporting to E_ALL.

davidethell
  • 11,708
  • 6
  • 43
  • 63
  • I am using >= 2.x version and `define('ENVIRONMENT', 'development');` is already defined at the top of index.php. – AppleGrew Sep 10 '11 at 10:19
  • Accepting your answer since your answer is short and concise, even though my issue was something unrelated. Your answer is what 90% people would be looking for. For people who are still facing issue, they may want to look at my answer. – AppleGrew Sep 12 '11 at 05:09
12

Create a .htaccess file in your webroot with the following content

php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
php_flag log_errors on
php_flag ignore_repeated_errors off
php_flag ignore_repeated_source off
php_flag report_memleaks on
php_flag track_errors on
php_value error_reporting -1
php_value log_errors_max_len 0

Hopefully that should enable your logs.
Make sure to set the values to off and reporting to 0 on your production server :)

Dennis Rasmussen
  • 520
  • 3
  • 12
2

Following environment settings would gonna force PHP to display errors as they occur:

  • APPLICATION ENVIRONMENT define('ENVIRONMENT', 'development'); /*
  • ERROR REPORTING

    if (defined('ENVIRONMENT')) { switch (ENVIRONMENT) { case 'development': // Report all errors error_reporting(E_ALL);

            // Display errors in output
            ini_set('display_errors', 1);
            break;
    
        case 'testing':
        case 'production':
            // Report all errors except E_NOTICE
            // This is the default value set in php.ini
            error_reporting(E_ALL ^ E_NOTICE);
    
            // Don't display errors (they can still be logged)
            ini_set('display_errors', 0);
        break;
    
        default:
            exit('The application environment is not set correctly.');
    }
    

    }

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
faryal rida
  • 379
  • 3
  • 6
  • 1
    I am glad it worked for me in Codeignitor, would it work for all PHP frameworks or are there any limitations which bounds it to work for all PHP frameworks? – Zulkifl Agha Sep 23 '19 at 18:47
1

I am not sure what was the real reason but I had a PHP installation with left-over php.ini file. Later I installed the full WAMP stack with its own PHP. When I deleted the leftover php.ini file from the previous installation then it started working as it should. It seems the PHP binaries in the new installing was using using the left-over php.ini which was in totally different directory; maybe because that directory was in environment PATH.

AppleGrew
  • 9,302
  • 24
  • 80
  • 124