The 10 Magento 2 Commandments


That’s it; Magento 2 is well and truly launched! The marketplace is in place, and the first extensions are already selling.But this is not without counting the phases of strict submissions that Magento imposes before being able to publish its own. Indeed, this new major version is accompanied by a new philosophy, which advocates standards, conventions and best practices. Folio3 magento development 2 wants to be more mature and only wants to address professionals. This is how the new “Trained Solution Partner” certificate was born. Exclusively for Magneto 2 and “Solution Partner” certification holders, this program is training on best practices and how to develop a Magento 2 extension in standards.

I – In developer mode to code, you will be!

Nothing is more natural than activating developer mode, to develop your extension! Developer mode will automatically disable the static file cache, enable automatic code compilation, and make debugging easier and more visible. 

Be careful, only activate developer mode for your developments. This causes slowdowns and considerably reduces performance.

II – PSR standards and conventions, you will respect!

As you will have understood, it is impossible to miss the different PSRs, conventions and standards with Magneto 2!

Here is a small exhaustive list of what you will have to respect:

Send Coding standards

PSR-1 “Basic Coding Standard”

PSR-2 “Coding Style Guide”

PSR-3 “Logger Interface”

PSR-4 “Autoloader”

III – Dependency injection, you will use!

Direct class instantiation is not recommended, the class you want to use may be overloaded by the Magneto 2 DI. Indeed, the directly instantiated class does not take into account the overloads declared in the di.xml. This is why it is essential to use dependency injection. In addition, it allows you to decouple your code, avoiding strong interdependencies between your classes. Your code becomes reusable and can be used as a “service”.

IV – Less inheritance and more composition, you will consider!

The philosophy between Magento 1 and Magneto 2 has radically changed on this subject. While in the 1st version, class inheritance is encouraged, it is neglected for class composition in its new version. But why this sudden change? This comes from an observation made by the technical team of Magneto. It turns out that the composition is much easier to maintain when a class is changed or when a feature is updated.

V – The functions of the framework, you will use!

Some native PHP functions are implemented by the Magneto 2 framework. It is therefore essential to use them to deal with any flaws. You will be able to find all the functions that you should no longer use in this list.

VI – the Magneto CodeSniffer Coding Standard, you will execute!

What could be better than a tool to check that all the rules stated above have been respected? This tool, based on PHP Code Sniffer, will automatically check that your code does not contain errors and that it respects the various standards of Magneto 2.You benefit from having a code which corresponds to Magneto 2 standards and which will easily pass the technical review phase. This simply aims to create code understandable by all, and therefore more easily maintainable! To use the Magneto CodeSniffer Coding Standard Tool, please follow these instructions.

VII – Unit tests, you will write!

If you are used to test-driven-development (TDD), unit tests certainly hold no secrets for you! If you don’t, just tell yourself that Magneto 2 favors extensions that have it. Not only will this ensure code non-regression and force you to think carefully during your analysis, but it will increase the confidence of developers who will use your extension. Indeed, it is a guarantee of quality and proves that the functional aspect of your extension is tested in its entirety.

VIII – Use the existing menus, you will!

On this point Magneto 2 is uncompromising! The extensions must be placed in the existing menus. Exit therefore the multiple entries in level 1 of the menu, as we could see on Magneto 1. This means that your extension must be categorized so as to respect the navigation of Magento 2 so as not to lose the user. Thus, if you develop an extension on products, it will be stored in the “PRODUCTS” menu. However, if your extension is exclusive and it implements something completely new, it will be stored in a section specially provided for this purpose. However, the name and icon for this section are still not defined by Magneto.

IX – the Admin Style Guide, you will respect!

Magneto 2 imposes its style! A list of rules specifies the formats you should use, including typography, iconography, layout grids, and color palette. Magneto 2 wants to standardize the style of the Backend in order to form a homogeneous whole.

X – Attentive to responsive design, you will be!

Don’t neglect mobile users! More and more customers are starting their purchases from a mobile. That’s why you have to bet everything on responsive design. If a visitor goes to your page and it takes too long to load, not adapted or illegible on his Smartphone (or on his tablet), you can be sure that he will not return to your site. Best Web Hosting Service avoiding these bad experiences, you will not only increase your conversion rate but also your traffic! Magneto 2 has thought of everything and has provided a section for you to best guide you in creating your responsive theme, don’t neglect it.

Read More : What is 6G & When Will It Emerge?

Digital marketing

Magento

Comments are disabled.