How to Enable Profiler for Magento 2 Stores
The launch of Magento 2 has brought a lot of benefits to e-commerce stores. Magento 2 offers a lot of powerful functions as well as integrated intelligent extensions. Creating a faster Magento 2 store is an easy job; however, it is difficult to predict how good an add-on will be as well as to know if it is suitable for a Magento store or not. There are now various tools that help you debug and measure which extensions on your store are taking up too much memory and consuming time. One of the most highly recommended internal debuggers that we would like to mention is Profiler.
In this blog post, we will learn How to Enable Profiler for Magento 2 stores.
Without further ado, let’s get started!
Table of Contents
- Benefits of Profiler for Magento 2 stores
- How to enable Magento 2 Profiler
- Check your results
- Common issue after enabling Magento 2 Profiler
- Final words
Benefits of Profiler for Magento 2 stores
Profiler is an internal debugging tool that plays an important role in the development of Magento. It is built in Magento, which helps to identify performance issues on your server. In addition, it also allows you to get a Magento partial load time report. Thanks to this, you can check and see which apps consume your memory and slow down the page load, and improve your online store page speed.
Currently, Magento supports 3 profiler formats: HTML, CSV file, and Firebug. All preset formats are used to analyze performance tasks, show dependency graphs on the Magento page, and reveal unused dependencies to cut down memory and time. You can totally solve all of the above by enabling Profiler in Magento 2.
Let’s jump right into detail!
How to enable Magento 2 Profiler
With previous versions of Magento 2, there are several ways to enable Profiler for eCommerce stores. With the current version, however, there is only one way to allow it. That is to use the .htaccess file. We will explore this step-by-step right now.
Step 1: Add the code in .htaccess file
All you need to do is add the code below in .htaccess file at Magento root directory:
# SetEnv MAGE_PROFILER html
Step 2: Set the value of MAGE_PROFILER
Next, please set the value of MAGE_PROFILER in 3 cases as the following:
- csv file: You can find the reports in /var/log/profiler.csv
- html: You can find the results in blocks of HTML code at the end of your store’s homepage
- firebug: You can find the reports in /var/log/profiler.csv using Firebug output
Step 3: Enable Magento 2 Developer mode
To enable Magento 2 Developer Mode, please log in to your SSH, navigate to your store root directory and run the following command:
php bin/magento dev:profiler:enable <type>
Step 4: Refresh the cache
Last but not least, you need to compile as well as refresh the cache to finish.
Check your results
Depending on your configuration, you will see the following output:
- In HTML Profiler: The Profiler should be placed below the footer of your online storefront. You just need to open the homepage, scroll down and you will see a list of timers_id and execution time of each timer as follows:
- CSV File: This file is stored in the var/log directory.
- Dependency graphs: You will see the results of the following page when trying to access your storefront as below:
Common issue after enabling Magento 2 Profiler
A fairly common error is that Magento 2 Profiler is not working.
Don’t worry since you can completely fix this problem by using other configuration modes like csvfile, etc, or make sure HTML Profiler doesn’t affect anything in the functionality.
Hire Magento Developers
What you need to do is only describing desired features of the Magento website, we will help you to build the store that ticks all the boxes!Get Started
After enabling the Profiler in Magento 2, you can easily detect the applications and software that take up a lot of memory, slow down your website system as well as the hidden reasons behind your poor performance.
If you find our article missed anything important or need to contribute another documentary, please feel free to leave a comment below.
Thanks a lot for reading!
Customization & Development Services?
8+ years of experiences in e-commerce & Magento has prepared us for any challenges, so that we can lead you to your success.Get free consultant