Cookies setting

Cookies help us enhance your experience on our site by storing information about your preferences and interactions. You can customize your cookie settings by choosing which cookies to allow. Please note that disabling certain cookies might impact the functionality and features of our services, such as personalized content and suggestions. Cookie Policy

Cookie Policy
Essential cookies

These cookies are strictly necessary for the site to work and may not be disabled.

Information
Always enabled
Advertising cookies

Advertising cookies deliver ads relevant to your interests, limit ad frequency, and measure ad effectiveness.

Information
Analytics cookies

Analytics cookies collect information and report website usage statistics without personally identifying individual visitors to Google.

Information
mageplaza.com

How to Enable Profiler for Magento 2 Stores

Vinh Jacker | 08-03-2021

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

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

Add the code in .htaccess file
Add the code in .htaccess file

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
Set the value of MAGE_PROFILER
Set the value of MAGE_PROFILER

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:
ALT_TITLE
CAPTION
  • CSV File: This file is stored in the var/log directory.
ALT_TITLE
CAPTION
  • Dependency graphs: You will see the results of the following page when trying to access your storefront as below:
ALT_TITLE
CAPTION

Common issue after enabling Magento 2 Profiler

A fairly common error is that Magento 2 Profiler is not working.

There will be some cases that HTML Profiler doesn’t work after you have enabled them in Magento. The most likely cause is the HTML code that causes javascript execution error.

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
hire magento developers

Final words

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.

We hope this tutorial can help you open up a magical world for your Magento 2 store. As a result, your online store will significantly improve performance and, subsequently increase sales efficiency.

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!

x
    Jacker

    With over a decade of experience crafting innovative tech solutions for ecommerce businesses built on Magento, Jacker is the mastermind behind our secure and well-functioned extensions. With his expertise in building user-friendly interfaces and robust back-end systems, Mageplaza was able to deliver exceptional Magento solutions and services for over 122K+ customers around the world.



    Related Post

    Website Support
    & Maintenance Services

    Make sure your store is not only in good shape but also thriving with a professional team yet at an affordable price.

    Get Started
    mageplaza services