How to enable profiler in magento2
To enable the profiler we can add it from index.php or apache/nginx conf file.
Enable/Disable Profiler from Command Line:
# Enable the profiler.
php bin/magento dev:profiler:enable
# Disable the profiler.
php bin/magento dev:profiler:disable
Enable Profiler from index.php:
- Open {magento root}\pub\index.php from magento2
- Add following line from the file $_SERVER["MAGE_PROFILER"]="html";
- Clear cache you can able to see the profiler.
Enable profiler from apache conf or magento2 .htaccess :
- We can also set the profile or enable the profiler from the Apache vhost file or .htaccess file.
- Open .htaccess from following path {magento root}\pub\static\.htaccess or {magento root}\.htaccess (here i have mentioned .htaccess file, while in development mode)
- Add following code in top of the .htaccess file, “SetEnv MAGE_PROFILER csvfile”
Enable profiler from nginx conf:
- Open nginx.conf file
- 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/