29

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?

32

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.

9

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

   $_SERVER['MAGE_PROFILER']=1;
  • This doesn't seem to work. – Maciej Paprocki Jun 13 '16 at 14:15
  • 1
    this is the tricky solution – Amit Bera Apr 12 '17 at 7:41
7

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

Try this module, it enable magento 2 profiler + add SQL queries profiler https://github.com/mirasvit/module-profiler

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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