CodeIgniter Forums
Anybody in favour of using PHP error reporting instead of Kint? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forum-29.html)
+--- Thread: Anybody in favour of using PHP error reporting instead of Kint? (/thread-79505.html)



Anybody in favour of using PHP error reporting instead of Kint? - John_Betong - 06-25-2021

I find Kint supplies a vast amount of inconsequential data and that PHP default error reporting is far better. 
Reason is that PHP stops on the first error, gives the file name and line number which is perfectly adequate.
I have modified the following file and prefer this method of Debugging:
File:  ./system/Debug/Exceptions.php
PHP Code:
# REACTIVATE PHP DEFAULT ERROR REPORTING 
        /**
        * Responsible for registering the error, 
          exception and shutdown handling 
          of our application.
        */
        public function initialize()
        {
          # Set the Exception Handler
            # John - 2021-06-26 - proposal
            if(CI_DEBUG) :
              set_exception_handler([$this'exceptionHandler']);

              # Set the Error Handler
                set_error_handler([$this'errorHandler']);

              # Set the handler for shutdown to catch Parse errors
              # Do we need this in PHP7?
                register_shutdown_function([$this'shutdownHandler']);
            endif;
        



RE: Anybody in favour of using PHP error reporting instead of Kint? - paulbalandan - 06-26-2021

As far as I know that is not Kint. Kint only powers a handful of global functions like `dd()` and `trace()`.


RE: Anybody in favour of using PHP error reporting instead of Kint? - John_Betong - 06-27-2021

(06-26-2021, 10:42 AM)paulbalandan Wrote: As far as I know that is not Kint. Kint only powers a handful of global functions like `dd()` and `trace()`.

I searched for "Kint" in the System folder and found the following references:

> 1413 matches across 95 files

When CI_DEBUG is activated there is a lot of inconsequential information displayed I find it not easy to trace Bugs.

The default PHP exceptionHandlers(), set_error_handler() and register_shutdown_function() all use Kint.

I prefer to use PHP default error handling rather than Kint and would like a .env option to deactivate Kint.

./System/ThirdParty/Kint/ ==> 98 items, totalling 415.9 kB


RE: Anybody in favour of using PHP error reporting instead of Kint? - John_Betong - 06-27-2021

Further improvements to the Original Post #1... modified the following:

File:  ./app/Config/Boot/production.php
<?php
PHP Code:
/*
 |--------------------------------------------------------------------------
 | ERROR DISPLAY
 |--------------------------------------------------------------------------
 | Don't show ANY in production environments. Instead, let the system catch
 | it and display a generic error message.
 */
ini_set('display_errors''0');
/*
 |--------------------------------------------------------------------------
 | DEBUG MODE
 |--------------------------------------------------------------------------
 | Debug mode is an experimental flag that can allow changes throughout
 | the system. It's not widely used currently, and may not survive
 | release of the framework.
 */
defined('CI_DEBUG') || define('CI_DEBUG'false);

# John 2021-06-28
  error_reporting(-1); // MAXIMUM ERROR REPORTING
  define('CI_ERROR_LOG''../writable/logs/log-' .date('Y-m-d') .'.log');
  ini_set('error_log'CI_ERROR_LOG);

  if( 'localhost'===$_SERVER['SERVER_NAME'] ):
    ini_set('display_errors''true');
  endif; 
[/php]

The advantage is that both local and online application will raise an error log page and only display errors locally. 

I think it is far better to log errors raised by the  Online Application rather than ignore errors by setting error_reporting(0);