CodeIgniter Basic Tutorial
Performance & Utilities
CodeIgniter Advanced
Application profiling in CodeIgniter is a debugging and performance analysis tool.
It helps developers see benchmarking results, database queries, memory usage, POST/GET data, and more.
The profiler is very useful when you want to:
To enable the profiler for a controller method:
class Welcome extends CI_Controller { public function index() { $this->output->enable_profiler(TRUE); $this->load->view('welcome_message'); } }
✅ Now, when you load the page, you’ll see profiling information at the bottom of the page.
You can disable it by passing FALSE
:
$this->output->enable_profiler(FALSE);
If you want profiler data on all pages, set it in the controller’s constructor:
class MY_Controller extends CI_Controller { public function __construct() { parent::__construct(); $this->output->enable_profiler(TRUE); } }
The profiler outputs:
You can choose which profiler sections to show or hide:
$sections = array( 'benchmarks' => TRUE, 'queries' => TRUE, 'memory_usage' => TRUE, 'post' => FALSE, 'config' => FALSE ); $this->output->set_profiler_sections($sections); $this->output->enable_profiler(TRUE);
✅ This will only show benchmarks, queries, and memory usage, while hiding others.
class Products extends CI_Controller { public function index() { $this->output->enable_profiler(TRUE); $data['products'] = $this->db->get('products')->result(); $this->load->view('product_list', $data); } }
👉 Now, when you load the Products page, you’ll see all executed queries and page performance details at the bottom.