Blog for Learning

| lesson material | material summary | questions and answers | definitions | types and examples | other information | materi pelajaran | ringkasan materi | pertanyaan dan jawaban | definisi | jenis-jenis dan contoh-contoh | informasi lainnya |

Powered by Blogger.


How to Activate the CodeIgniter Profiler

Profiler serves to display some of the information needed in developing and debugging applications.
With profilers we can see:
  • The time needed to execute the controller
  • What queries are executed
  • Query execution speed
  • Data sent
  • etc.
This information is very useful when we build applications with CodeIgniter.

Enable the CodeIgniter Profiler

How to activate Profiler on CodeIgniter is very easy, just by running this function in the controller .
Then we will get information like the following:
CodeIgniter Profiler
Then, for the Profiler to be active in each method or function, put the code in the constructor:
function __construct(){

    // untuk debugging

Disable the CodeIgniter Profiler

How to disable it, we can delete the function or change its parameters to false.
But later the problem is, when we want to deploy to the server ...
... we have to change each profiler function to FALSE.
This is not effective.
Then what is the solution?
The solution is we can use variables ENVIRONTMENT.
$this->output->enable_profiler(ENVIRONMENT == 'development');
So if the value of the variable ENVIRONTMENTis development(localhost), then it will produce a value TRUE.
But if the value of a variable ENVIRONTMENTis production, it will produce a value FALSE.
We can create variables ENVIRONTMENTinside index.php:
  case "localhost":
      define('ENVIRONMENT', 'development');
      define('ENVIRONMENT', 'production');
0 Komentar untuk "How to Activate the CodeIgniter Profiler"

Silahkan berkomentar sesuai artikel

Template By Kunci Dunia
Back To Top