Magento Introduction And Architectural

Magento Introduction And Architectural

目录:

  1. Magento Introduction

  2. Magento Technology stack

  3. Architectural basics overview

  4. Architectural layers overview

  5. Magento components

  6. Logical view overview

  7. Reference

Magento Basic Introduce

  1. The Magento Framework is integrated with the following software layers:

    1. Presentation layer provides both view components (layouts, blocks, templates) and controllers, which process commands to and from the user interface

    2. Service layer, through the use of service contracts, defines the overall interface for interacting with business logic (for example, creating customers and getting tax rates).

    3. Domain layer provides core business logic and functionality in base classes, resource models, and data access capabilities that you can extend and customize. Business logic rules, which define how data is retrieved from the database and manipulated, are stored in the Business Logic layer.

  2. Ease of extensibility - Magento uses dependency injection and service contracts to simplify the process of supplying a new implementation of a defined API.

  3. Modularity - Modules form the basic functional unit of a Magento system. Magento modules contain the logic to execute required actions and functions. You extend the core feature set of Magento by writing and incorporating new modules into your installation

Mangeto Technology Stack

NameDescription
Web serversApache/nginx
LanguangePHP - Composer (dependency management package for PHP)
DatabaseMySQL/MySQL Percona
HTTP acceleratorVarnish
Cache StorageRedis/Memcache
SearchSolr (Magento Enterprise Edition only)/Elasticsearch (Magento Enterprise Edition version 2.1.x only)
Additional technologiesHTML5/CSS3(LESS)/jQuery/RequireJS/Knockout.js/Third-party libraries (Zend Framework 1, Zend Framework 2, Symfony)
Optional stack componentsVarnish (caching)/Redis (used for page caching)
  • Magento also provides automated testing suites that include unit, integration, functional and performance test scripts, as well as JavaScript tests and tools for static code analysis. Components include PHPUnit for the unit test framework and Selenium for the functional test framework.

Architectural basics overview

  1. Extensibility and modularity

    1. architectural principles that guide product structure

        * oftware development is the practice of replacing or extending core code rather than editing it
    2. open-source software to create and manage extensions

        * Composer
    3. coding standards - Magento Coding Standards

    4. upgrade and versioning strategies

  2. Ease of frontend customization
    The Magento frontend is designed to optimize storefront customization. Merchants are encouraged to use Magento components to customize the look-and-feel of their storefronts.

    1. Magento Blank theme

        * The Magento blank theme template provides a launchpad for storefront customization.
    2. Magento UI components

        * The Magento UI library is a set of generic web components and Magento-specific patterns, which simplifies the process of Magento theme creation and customization.
    3. Magento Admin pattern library

        * A pattern library is a collection of user interface (UI) design patterns that can be re-used in locations throughout your product installation.
  3. Global features that support extensibility

    1. Modularity - The concept of the module is the heart of Magento extension development, and modular design of software components (in particular, modules, themes, and language packages) is a core architectural principle of the product.

    2. Reliance on popular design patterns - Magento product architecture incorporates many well known patterns, but Model-View-Controller (MVC) holds particular interest for extension developers.

    3. Coding standards - Magento developers should familiarize themselves with our coding standards

    4. Rich product ecosystem - The wider Magento ecosystem provides an extensive community and rich third-party marketplace for extensions

    5. Flexible attribute types

        1. EAV (Entity-Attribute-Value) attributes are site-specific attributes that you can define for a local site using the Magento Admin.
        2. Custom attributes are a subset of EAV attributes. Objects that use EAV attributes typically store values in several MySQL tables. The Customer and Catalog modules use EAV attributes.
        3. Extension attributes often use more complex data types than custom attributes. These attributes do not appear in the storefront. Extension attributes are introduced by modules.
    6. Web APIs - Magento or third-party services can be configured as a web API (REST or SOAP) with some simple XML integrate CRM CMS ERP

    7. Service contracts, dependency injection, and dependency inversion - Service contracts provide a new way to access public API endpoints.

    8. Plug-ins - Plug-ins, like modules, are a mechanism for adding features to the core Magento product

  4. Storefront customization strategies

    1. Extend Magento-Provided CSS - Magento supplies a default theme and a LESS-based CSS set of styles.

    2. Replace PHTML template files - In addition to extending the default CSS, you can generate different HTML markup.

    3. Replace Magento - Provided CSS - Rather than edit the default CSS provided by Magento, you might decide to replace all the default storefront CSS code with your own.

    4. Replace Magento - Provided CSS, HTML, and JavaScript - Delivering a sharply different shopping experience than the default Magento installation provides is a more substantial task.

Architectural layers overview

  1. Presentation layer

    1. Who uses the Presentation layer?

        * **Web users** These users work within the (frontend) area
        * **System administrators** customizing a storefront can indirectly manipulate the presentation layer by
        * **Web API** calls can be made through HTTP just like browser requests, and can be made via AJAX calls from the user interface.
  2. Service layer
    The service layer provides a bridge between the presentation layer and the model layer of domain logic and resource-specific data

    1. Who accesses the service layer?

        * Controllers (initiated by actions of users of the storefront)
        * Web services (SOAP and REST API calls)
        * Other Magento modules through service contracts
  3. Domain layer
    The domain layer holds the business logic layer of a Magento module.

Best practice: Use service contracts to communicate to the domain layer by passing data types through strongly typed objects. This practice can help you avoid the need to replace presentation layer code when replacing business layer logic.

1. Who accesses the domain layer?
    * Service contracts are the recommended way for one module to access another module’s domain-level code.
    * A module can directly call into another module.
    * Domain layer code in one module can also plug itself into another module by:    
        1. event hooks
        2. plugins
        3. `di.xml` files (with an SPI contract)
  1. Persistence layer
    Magento uses an active record pattern strategy for persistence

    1. Executing all CRUD (create, read, update, delete) requests. The resource model contains the SQL code for completing these requests.

    2. Performing additional business logic

Magento components

  1. Module overview

    1. Module purpose - The purpose of each module is to provide specific product features by implementing new functionality or extending the functionality of other modules.

    2. Module components - A module is a directory that contains the PHP and XML files (blocks, controllers, helpers, models) that are related to a specific business feature,

    3. Where do modules live?

        * Modules typically live in the `app/code` directory of a Magento installation, in a directory with the following PSR-0 compliant format: `app/code/<Vendor>/<ModuleName>`
  2. Module Magento area types

    1. Magento Admin (adminhtml): entry point for this area is index.php or pub/index.php.

    2. Storefront (frontend): entry point for this area is index.php or pub/index.php

    3. Basic (base): used as a fallback for files absent in adminhtml and frontend areas.

    4. Web API REST (webapi_rest): entry point for this area is index.php or pub/index.php.

    5. Web API SOAP (webapi_soap): entry point for this area is index.php or pub/index.php.

    6. Quick view of module/area interactions

        * Modules should not depend on other modules’ areas.
        * Disabling an area does not result in disabling the modules related to it.
        * Areas are registered in the Dependency Injection framework `di.xml` file.
    7. Module Name and declare the module in the module.xml file.

  3. Magento themes
    Custom theme development is one of two main methods of modifying Magento behavior and storefront appearance. (Extending modules is the other primary way, and the main way to tailor Magento behavior.)

    1. Theme location

        * The location of a theme in your Magento installation depends upon how you installed your theme. Magento knows to look in both `vendor` and `app/design` for themes. In Magento 2.0, each module and theme contain a `registration.php` file, which defines location information.
    2. Location of themes when installing with Composer

    3. Location of custom themes - not recommended

        * While developing a theme, place it under app/design. If you’ve defined the theme for a local project (that is, you intend to install it in one project only), place it under app/design
  4. Language packages and translation

    1. Magento language packages

        1. `.csv` file contains the actual strings that comprise the language dictionary. 
        2. `composer.json` file contains any dependencies for the language package and a mapping to its defined locale.
        3. `language.xml` file, where you declare a language package and establish any inheritance rules, if you are installing multiple language packages.
      

Logical view overview

  1. Magento libraries

  2. Magento Framework

    1. Magento Framework organization - Lib/ ../Internal ../Magento ../Framework

        * `/lib/internal` contains some non-PHP as well as PHP components. Non-PHP framework libraries includes JavaScript and LESS/CSS.
        * `/lib/internal/Magento/Framework` contains only PHP code.
        * `/lib/web` contains JavaScript and CSS/LESS files.
        *  `lib/internal/Magento/Framework` directory maps to the `Magento\Framework` namespace.
    2. Magento Framework Function - Magento Framework Function

Reference

  1. Magento technology stack

  2. Architectural diagrams

  3. What is Magento?

标签: none

添加新评论