New Magento Recommendations, Courtesy of Agence DnD

By Matthéo Geoffray, on Sep 03, 2019

This blog post is written by Matthéo Geoffray, Lead Developer at Agence DnD, Blackfire Contributor.

As a Magento partner agency, DnD takes pride in respecting the best practices of the solution and cares especially about security and performance. That’s why we were interested in Blackfire.io.

Blackfire has a Magento 2 specific add-on containing the best practices of the platform around three axes:

  • Performance
  • Security
  • Quality

As a Blackfire Contributor, our close relation with the Blackfire team made it possible for us to expand the list of recommendations with the following:

  • The Magento 2 Profiler should not be called on production mode
  • The Magento 2 DB Logger should not be called on production mode
  • OPcache “save_comments” should be enabled on Magento 2

Let’s have a closer look at what those mean!

The Magento 2 Profiler should not be called on production mode

The Magento profiler is used to analyze the performance of the platform. It must be disabled on production environments for the following reasons:

  • Performance: The profiler will store all the information to be displayed in the output during the application runtime. This takes memory and processing time.
  • Security: The profiler will display sensitive information such as:
    • PHP classes
    • Template files
    • Observers and events
    • Layouts
    • Controllers

You can disable it via this command line

bin/magento dev:profiler:disable

The Magento 2 DB Logger should not be called on production mode

The Magento DB Logger allows you to analyze all the SQL queries of the platform. It must be disabled on production environments for the following reasons:

  • Performance: the logger will write in a file all the SQL queries executed on platform as well as the details of all the PHP process that led to the request.
  • Security: sensitive information can be contained in the requests and in the details of the PHP process

You can disable it via this command line

bin/magento dev:query-log:disable

OPcache “save_comments” should be enabled on Magento 2

The opcache.save_comments option allows OPcache to keep code comments in the cache. It must be enabled on all environments for quality reasons.

Many applications including Magento rely on these comments in their internal logic. It is therefore important to keep them activated to ensure that the platform works properly.

You can enable this option with the following line:

opcache.save_comments=1

Happy Magento profiling,

Matthéo Geoffray

After his training and graduating in Engineering and Multimedia, Matthéo Geoffray joined Dn'D Agency in 2011. On the 2013, 2014 and 2018 years it will get Magento official certifications Developer, Developer Plus and Professional Developer Magento 2. He contributed to the technical development of the Agency as Lead Developer.