THE APP DEVELOPMENT FRAMEWORK OF MAGENTO

01/02/2020 835
APP DEVELOPMENT E-COMMERCE

The Magento app development framework manages the interaction of application components containing request flow, routing, indexing, caching, and exception handling. This framework can provide services reducing the effort of creating modules include business logic, contributing to make Magento code more modular and decrease dependencies.

 The logical groups named “libraries” included primary PHP software components. Most of the framework code sits under the domain layer or encloses the presentation, service, and domain layers. Normally, the framework contains no business logic. (This framework does not possess resource models but it does have a library of code to implement a resource model.)

Modifying app development framework files is unnecessary. If you are extending Magento, you just need to call Framework libraries. Modules you create will typically inherit from classes and interfaces defined in the Framework directories. 

Next up, we will introduce to you about responsibilities, operations and highlights of the Magento app development framework.

Responsibilities

 The libraries supplied by the Magento framework will reduce your effort in creating modules including business logic.

 The operations (responsible by the framework) are useful for potentially all modules, concluding: 

  • handling HTTP protocols
  • interacting with the database and filesystem
  • rendering content

Organization

Here is the Magento App Development Framework folder structure:

vendor/

    ../magento

        ../framework

lib/

    ../internal

        ../LinLibertineFont

    ../web

  • /vendor/magento/framework includes only PHP code. These are libraries of code plus the application entry point that routes requests to modules (that in turn call the Framework libraries). For instance, libraries in the Framework help implement a resource model (base classes and interfaces to inherit from) but not the resource models themselves. While certain libraries also support CSS rendering.
  • /lib/internal contains some non-PHP as well as PHP components. Besides, Non-PHP framework libraries includes JavaScript and LESS/CSS.
  • /lib/web contains JavaScript and CSS/LESS files which reside under web and not internal because they are accessible from a web browser, while the PHP code under internal is not. (Any code that a web browser must access should be under web, while everything else under internal.)
  • The vendor/magento/framework directory maps to the Magento\Framework namespace.

Highlights of Magento Framework

  • The Magento structure (lib/internal/Magento/Framework/) provides a robust range of functionality.  Perhaps, extension developers may be interested in this subset of Framework namespaces.

NamespacePurpose
Magento\Framework\DataObjectStandard functionality for storing and retrieving data, which is the base class for many Magento classes.
Magento\Framework\ModelBase Model classes that almost all Magento Model classes extend from.
Magento\Framework\Model\AbstractModel 
Magento\Framework\Model\ResourceModel\AbstractResource 
Magento\Framework\ControllerClasses to help return different types of results (for example, redirects).
Magento\Framework\ViewCode to render pages and layouts.
Magento\Framework\DataAdditional classes that handle forms.
Magento\Framework\UrlCode to look up other pages in Magento.

 

  • Other namespaces under Magento\Framework that will interest extension developers:

NamespacePurpose
Magento\Framework\ObjectManagerProvide dependency injection.
Magento\Framework\AppFramework code of the Magento application. Functions of this code: bootstraps the application, reads in initial configuration, contains the entry point to the command line tools/the web application/the cron job,routes requests, provides the deployment context.
Magento\Framework\ApiBase classes for advanced functionality of extendable objects through the system (Add new data through Magento Marketplace extensions to extend objects).
Magento\Framework\ConfigThe generic configuration reader file which has its own specialized reader extending these classes.
Magento\Framework\FilesystemClasses that handle reading from and writing to the file system.
Magento\Framework\HTTP\PhpEnvironment 
Magento\Framework\Session 
Magento\Framework\Stdlib\CookieCode to handle the HTTP request/responses with session/cookies is found here.
Magento\Framework\ExceptionThe basic exceptions that are thrown via the Magento codebase.
Magento\Framework\EventCode which publishes synchronous events that handles observers for any Magento event is handled here.
Magento\Framework\ValidatorCode that validates data (currencies, not empty) and handles observers for any Magento event.
 
Join us