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?

5
  • Could you give the output of phpinfo() inside of your CI-Program? What does trigger_error('test', E_USER_NOTICE) give you? Commented Sep 10, 2011 at 8: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. Commented Sep 10, 2011 at 8: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! :) Commented Sep 10, 2011 at 11:59
  • This helped me, try it: stackoverflow.com/questions/9587413/… Commented Feb 6, 2013 at 18:12
  • I found this solution: stackoverflow.com/questions/9587413/… It worked for me. Commented Feb 6, 2013 at 18:15

4 Answers 4

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.

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

2 Comments

I am using >= 2.x version and define('ENVIRONMENT', 'development'); is already defined at the top of index.php.
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.
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 :)

Comments

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.');
    }
    

    }

1 Comment

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

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.