Magento 2 technology stacks

      No Comments on Magento 2 technology stacks

I’ve been developing Magento 1 from quite a good time and now I’m working on Magento 2. Today I’ll be briefing few of the major changes I see in Magento 2 compared to Magento 1 in terms of technology stacks and modular structure.

PHP Versions

PHP 7 came with drastically improved performance when compared to PHP 5.6 and Magento 2 supports PHP 7.  Though Magento 2.0 and 2.1 supported PHP 5.6 but from Magento 2.2 onwards Magento is dropping support for PHP 5.6  and going forward only PHP 7.x will be supported.

Modularization

Even though Magento 1 was having a modular structure a lot of rework has been done in Magento 2 with respect to modularization. Dependency of  one module is reduced on another module. In Magengo 1 while developing a functionality I had to place php classes, xml files, templates, skin files in different directories. It was not very easy to figure out how many files are related to a particular module, but while developing modules in Magento 2 we keep all files of the module in one directory Vendor/Module.

Few of the existing modules like grouped and configurable product are not separated and we can easily disable any one of them if we want.

Magento 2 gives us flexibility to write area specific code. In case of Magento 1 if I had to write a router for frontend or admin I used to go to my module’s etc/config.xml file and add it . Though in Magento 2 I write it in area specif files. For example I add a router for frontend in my module’s etc/frontend/routes.xml file and for admin in etc/adminhtml/routes.xml file. See the difference ?. Code is more structured.

Less instead of plain css

Both css and less is used for UI designing. Magento 1 supported plain css code though Magento 2 supports less which is a CSS pre-processor, meaning that it extends the CSS language and add features that allows us to define css variables, mixins and functions making css a more extendable language.

Here is one example code in less structure which shows how less variables can be defined and used :


@myColor1: navy;
@myColor2: #000080;
@myStringVar: "with an appended string";
@myFontSize: 24px;
@thinBorder: 4px solid @myColor1;
@paddingVar: 15px 15px 15px 35px;
h1, h2 {
color: @myColor1;
}
#mypara {
font-size: @myFontSize;
border: @thinBorder;
padding: @paddingVar;
}
#mypara:after {
content: @myStringVar;
}

 

Symfony (console-component)

Console component tool of Symphony framework is used in Magento 2. It provides us with a simple framework to create our own command line tools. You can use console commands for indexing , database upgrades, cache cleanup, static content deployment and many more jobs.

Composer

Composer is a package manager for PHP libraries. With the help of composer you can easily download or upgrade php libraries, update only one specific library, without updating all your dependencies. I’ll write a separate post on composer.

Require JS

RequireJS is a JavaScript file and module loader. RequireJS reduces the number of http requests on the page and improves the speed and quality of your code by breaking large application into smaller manageable code. It only loads the JS script that the page needs.. I’ll write a detailed blog on require JS and how we can use it in Magento 2 in coming future. Stay tuned 🙂

Grunt

In Magento 2 grunt helps us in debugging code, compiling less files, concatenating and minifying CSS and JavaScript files, compressing images and applying changes to a server or files on the server. For details check official  documentation Compile LESS with Grunt.

There are a lot of other advanced tech stacks used in or compatible with Magento 2. Though I will stop this post here but will surely discuss few of the tech stacks in upcoming posts.

Leave a Reply