33

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?

0

3 Answers 3

35

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.

3
12

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 2/Adobe Commerce documentation

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;
}
11

By adding the below code to the root folder index.php works for me

   $_SERVER['MAGE_PROFILER']=1;
3
  • This doesn't seem to work. Jun 13, 2016 at 14:15
  • 1
    this is the tricky solution
    – Amit Bera
    Apr 12, 2017 at 7:41
  • worked..thanks :) Jul 29, 2019 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.