Magento 2: Is there a Profiler?
-
12-12-2019 - |
Question
Does Magento 2 have a profiler? The
Stores -> Settings -> Configuration -> Developer -> Debug
panel still exists, but there's no settings for a profiler there.
If Magento 2 does have a profiler, is it configurable via the GUI?
If it's not configurable with the GUI, how do you enable it?
Solution
To trigger built-in Magento2 profiler, just add a SetEnv MAGE_PROFILER "html"
to your .htaccess
. You can also use "csvfile"
or "firebug"
. In case of CSV, you'll find it in your var/log.
OTHER TIPS
By adding the below code to the root folder index.php works for me
$_SERVER['MAGE_PROFILER']=1;
From v2.2.4 and above
From version 2.2.4 you can now enable/disable Profiler from the CLI :
# Enable the profiler.
bin/magento dev:profiler:enable
# Disable the profiler.
bin/magento dev:profiler:disable
Source : Magento Open Source 2.2.4 Release Notes and Magento Commerce 2.2.4 Release Notes
For older versions
If you are running on a server with nginx (with fastcgi) :
Put this code on the PHP entry point
fastcgi_param MAGE_PROFILER html;
Using Magento 2 nginx.conf.sample file config, you would have a node like :
# PHP entry point for main application
location ~ (index|get|static|report|404|503|health_check)\.php$ {
try_files $uri =404;
fastcgi_pass fastcgi_backend;
fastcgi_buffers 1024 4k;
# Profiler
fastcgi_param MAGE_PROFILER html;
fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=18000";
fastcgi_read_timeout 600s;
fastcgi_connect_timeout 600s;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Try this module, it enable magento 2 profiler + add SQL queries profiler https://github.com/mirasvit/module-profiler