How to enable profiler in magento2

To enable the profiler we can add it from index.php or apache/nginx conf file.

Enable Profiler from index.php:

  1. Open {magento root}\pub\index.php from magento2
  2. Add following line from the file $_SERVER[“MAGE_PROFILER”]=”html”;
  3. Clear cache you can able to see the profiler.

 

Enable profiler from apache conf or magento2 .htaccess :

  1. We can also set the profile or enable the profiler from the Apache vhost file or .htaccess file.
  2. Open .htaccess from following path {magento root}\pub\static\.htaccess or {magento root}\.htaccess (here i have mentioned .htaccess file, while in development mode)
  3. Add following code in top of the .htaccess file, “SetEnv MAGE_PROFILER csvfile”

Enable profiler from nginx conf:

  1. Open nginx.conf file
  2. Add following line “fastcgi_param MAGE_PROFILER html” from ngnix.conf


Example:1 from nginx.conf file, enable following line.
fastcgi_param MAGE_PROFILER $MAGE_PROFILER;
 

Example: 2 Set profiler format:

server {
listen 80;
listen 443 ssl;
ssl_certificate /etc/ssl/certs/local/local.pem;
ssl_certificate_key /etc/ssl/certs/local/local.key;
server_name test.com;
set $MAGE_MODE developer;
set $MAGE_PROFILER html;
include /test.com/html/www/nginx.conf;
}


/etc/ngnix/conf.d/