Welcome Guest, Not a member yet? Register   Sign In
ci3 profilling in constructor fails
#1

Hi
I am trying to profile my application, but instead of putting the profiling code in each and every function I tried to put it in the class constructor as follows



PHP Code:
function __construct(){
$this->output->enable_profiler(TRUE);


but it threw the following error

Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined property: Users::$output

Filename: controllers/Users.php

Line Number: 16

Backtrace:

File: D:\xampp\htdocs\ci4\application\controllers\Users.php
Line: 16
Function: _error_handler

File: D:\xampp\htdocs\ci4\index.php
Line: 292
Function: require_once

( ! ) Fatal error: Uncaught TypeError: Argument 1 passed to CI_Exceptions::show_exception() must be an instance of Exception, instance of Error given, called in D:\xampp\htdocs\ci4\system\core\Common.php on line 662 and defined in D:\xampp\htdocs\ci4\system\core\Exceptions.php on line 190
( ! ) TypeError: Argument 1 passed to CI_Exceptions::show_exception() must be an instance of Exception, instance of Error given, called in D:\xampp\htdocs\ci4\system\core\Common.php on line 662 in D:\xampp\htdocs\ci4\system\core\Exceptions.php on line 190
Call Stack
#    Time    Memory    Function    Location
1    0.5270    1201488    _exception_handler( )    ...\Common.php:0
2    0.5270    1201488    CI_Exceptions->show_exception( )    ...\Common.php:662
A PHP Error was encountered

Severity: Error

Message: Uncaught TypeError: Argument 1 passed to CI_Exceptions::show_exception() must be an instance of Exception, instance of Error given, called in D:\xampp\htdocs\ci4\system\core\Common.php on line 662 and defined in D:\xampp\htdocs\ci4\system\core\Exceptions.php:190 Stack trace: #0 D:\xampp\htdocs\ci4\system\core\Common.php(662): CI_Exceptions->show_exception(Object(Error)) #1 [internal function]: _exception_handler(Object(Error)) #2 {main} thrown

Filename: core/Exceptions.php

Line Number: 190

Backtrace:

I was under the impression that the constructor will be called before every function call so what happened here. Sad
Reply
#2

(This post was last modified: 06-07-2020, 10:04 PM by php_rocs.)

@mike433,

Why are you adamant about profiling your application? There is useful information available at other locations (on the internet) that could possible give you the necessary information that you are seeking. Also, have you read the documentation ( https://codeigniter.com/userguide3/gener...=benchmark )?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB