Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 818f424

Browse files
authored
Merge pull request magento#4778 from magento/db_architecture
Update architecture guide
2 parents ad9cee6 + d15201e commit 818f424

File tree

35 files changed

+622
-309
lines changed

35 files changed

+622
-309
lines changed

_data/toc/architecture-guide.yml

Lines changed: 18 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,36 @@ pages:
77
url: /architecture/archi_perspectives/ABasics_intro.html
88
children:
99

10-
- label: Extensibility and modularity
11-
url: /architecture/extensibility.html
12-
13-
- label: Ease of frontend customization
14-
url: /architecture/frontend_custom_strategies.html
15-
16-
- label: Global features that support extensibility
17-
url: /architecture/global_extensibility_features.html
18-
19-
- label: Security
20-
url: /architecture/security_intro.html
21-
22-
- label: Storefront customization strategies
23-
url: /architecture/storefront_customization.html
24-
2510
- label: Architectural diagrams
2611
url: /architecture/archi_perspectives/arch_diagrams.html
2712

28-
- label: Technology stack
29-
url: /architecture/tech-stack.html
13+
- label: Frontend customization
14+
url: /architecture/frontend_custom_strategies.html
3015

3116
- label: Architectural layers
3217
url: /architecture/archi_perspectives/ALayers_intro.html
3318
children:
3419

20+
- label: Domain layer
21+
url: /architecture/archi_perspectives/domain_layer.html
22+
23+
- label: Persistence layer
24+
url: /architecture/archi_perspectives/persist_layer.html
25+
3526
- label: Presentation layer
3627
url: /architecture/archi_perspectives/present_layer.html
3728

3829
- label: Service layer
3930
url: /architecture/archi_perspectives/service_layer.html
4031

41-
- label: Domain layer
42-
url: /architecture/archi_perspectives/domain_layer.html
32+
- label: Coding Standards
33+
url: /coding-standards/bk-coding-standards.html
4334

44-
- label: Persistence layer
45-
url: /architecture/archi_perspectives/persist_layer.html
35+
- label: Magento Framework
36+
url: /architecture/archi_perspectives/framework.html
4637

47-
- label: Components
48-
url: /architecture/archi_perspectives/components/AComponents.html
38+
- label: Modules and Extensibility
39+
url: /architecture/extensibility.html
4940
children:
5041

5142
- label: Module overview
@@ -54,29 +45,15 @@ pages:
5445
- label: Modules and areas
5546
url: /architecture/archi_perspectives/components/modules/mod_and_areas.html
5647

57-
- label: Module conventions
58-
url: /architecture/archi_perspectives/components/modules/mod_conventions.html
59-
6048
- label: Module relationships
6149
url: /architecture/archi_perspectives/components/modules/mod_relationships.html
6250

6351
- label: Module dependencies
6452
url: /architecture/archi_perspectives/components/modules/mod_depend.html
6553

66-
- label: Module dependency types
67-
url: /architecture/archi_perspectives/components/modules/mod_depend_types.html
68-
69-
- label: Magento Framework
70-
url: /architecture/archi_perspectives/framework.html
71-
72-
- label: Third-party libraries
73-
url: /architecture/archi_perspectives/third-party-libs.html
74-
75-
- label: GDPR compliance
76-
include_versions: ["2.1", "2.2", "2.3"]
54+
- label: Technical vision
55+
url: /architecture/archi_perspectives/tech-vision.html
7756
children:
78-
- label: Magento 2.x
79-
url: /architecture/gdpr/magento-2x.html
8057

81-
- label: Magento 1.x
82-
url: /architecture/gdpr/magento-1x.html
58+
- label: Web Api
59+
url: /get-started/bk-get-started-api.html

_data/toc/configuration-guide.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,3 +415,12 @@ pages:
415415
- label: Development environment recommendations
416416
include_versions: ["2.1"]
417417
url: /config-guide/prod/development-environment.html
418+
419+
- label: GDPR compliance
420+
include_versions: ["2.1", "2.2", "2.3"]
421+
children:
422+
- label: Magento 2.x
423+
url: /architecture/gdpr/magento-2x.html
424+
425+
- label: Magento 1.x
426+
url: /architecture/gdpr/magento-1x.html
132 KB
Loading

guides/v2.1/architecture/archi_perspectives/arch_diagrams.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ Depending upon your role and purpose for learning more about Magento, there are
1010

1111
## Architecture layers diagram {#archi-layers}
1212

13-
The following diagram illustrates the components of Magento, and shows the "layers" or tiers, for all components, as well as the Magento framework, 3rd party libraries, the supported database, and other technologies.
13+
The following diagram illustrates the components and shows the "layers" or tiers in Magento.
1414

15-
[Magento architecture layers]({{site.baseurl}}/common/images/archi_diagrams_layers_alt4.jpg)
15+
![]({{site.baseurl}}/common/images/archi_diagrams_current.png)
1616

1717
## Related topics
1818

19-
* [Architecture layers overview]({{page.baseurl}}/architecture/archi_perspectives/ALayers_intro.html)
19+
* [Architecture layers overview]({{page.baseurl}}/architecture/archi_perspectives/ALayers_intro.html)

guides/v2.1/architecture/archi_perspectives/components/modules/mod_and_areas.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Each area declares itself within a module. All resources specific for an area ar
3838

3939
You can enable or disable an area within a module. If this module is enabled, it injects an area's routers into the general application's routing process. If this module is disabled, Magento will not load an area's routers and, as a result, an area's resources and specific functionality are not available.
4040

41-
### Quick view of module/area interactions
41+
### Module/area interaction guidelines
4242

4343
* Modules should not depend on other modules' areas.
4444

@@ -52,9 +52,8 @@ Magento processes a URL request by first stripping off the base URL. The first p
5252

5353
After the area name, the URI segment specifies the *frontname*. When an HTTP request arrives, Magento extracts the handle from the URL and interprets it as follows: `[frontName]/[controller folder]/[controller class]` where `frontName` is a value defined in the module. For example, in `catalog/product/view`, `catalog` is the name of the module used, `product` is the controller folder, and `view` is the controller class. For deeper directory structures, the controller folders are separated with `_` (for example, `catalog/product_compare/add` for `Magento/Catalog/Controller/Product/Compare/Add.php`).
5454

55-
Note that only the **execute()** method of any given controller is executed.
55+
Note that only the **execute()** method of any given controller is executed.
5656

5757
## Related topics {#m2arch-module-related}
5858

59-
[Module overview]({{page.baseurl}}/architecture/archi_perspectives/components/modules/mod_intro.html)
60-
59+
[Module overview]({{page.baseurl}}/architecture/archi_perspectives/components/modules/mod_intro.html)

guides/v2.1/architecture/archi_perspectives/components/modules/mod_depend.md

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,38 @@ Each Magento [module](https://glossary.magento.com/module) is responsible for a
1818

1919
* Removing or disabling a module does not result in disabling other modules.
2020

21-
## What components can modules depend upon?
21+
## Two types of dependencies {#m2devgde-moddep-declare-dep}
22+
23+
There are two types of Magento {% glossarytooltip c1e4242b-1f1a-44c3-9d72-1d5b1435e142 %}module{% endglossarytooltip %} dependencies: hard and soft.
24+
25+
### Hard dependencies
26+
27+
A module with a *hard dependency* on another module cannot function without the module it depends on. These modules:
28+
29+
* Contain code that directly uses logic from another module, such as class constants, static methods, public class properties, interfaces, and traits.
30+
* Contain strings that include class names, method names, class constants, class properties, interfaces, and traits from another module.
31+
* Deserializes an object declared in another module.
32+
* Uses or modifies the database tables used by another module.
33+
34+
### Soft dependencies
35+
36+
A module with a *soft dependency* on another module can function properly without the other module, even if it has a dependency on the other module. These modules:
37+
38+
* Directly check another module's availability.
39+
* Extend another module's configuration.
40+
* Extend another module's {% glossarytooltip 73ab5daa-5857-4039-97df-11269b626134 %}layout{% endglossarytooltip %}.
41+
42+
{:.bs-callout .bs-callout-tip}
43+
If a module uses code from another module, it should declare the dependency explicitly.
44+
45+
## Module install order
46+
47+
Magento installs modules in the following order:
48+
49+
1. The module serving as a dependency for another module
50+
2. The module dependent on it
51+
52+
## Appropriate dependencies
2253

2354
Although Magento architecture favors loosely coupled software components, modules can contain dependencies upon these software components:
2455

@@ -31,6 +62,31 @@ Although Magento architecture favors loosely coupled software components, module
3162
{:.bs-callout .bs-callout-tip}
3263
Note: You can lose the historical information contained in a module if the module is removed or disabled. We recommend alternative storage of module information before you remove or disable a module.
3364

65+
## Inappropriate dependencies {#m2devgde-moddep-inapp-dep}
66+
67+
Avoid creating these dependencies:
68+
69+
* Circular (both direct and indirect)
70+
* Undeclared
71+
* Incorrect
72+
73+
## Dependencies between modules in different presentation layers {#m2devgde-moddep-diff-layer}
74+
75+
You can build dependencies between the modules belonging to different layers.
76+
77+
## Dependencies in the Framework layer {#m2devgde-moddep-frmwk-layer}
78+
79+
A module belonging to the Magento Framework can be used in the application layer by an explicit dependency.
80+
81+
{:.bs-callout .bs-callout-tip}
82+
In this case, using interfaces is preferable to using classes. You can build dependencies between classes in the Magento Framework even if they belong to different modules.
83+
84+
## Dependencies in the application layer {#m2devgde-moddep-app-layer}
85+
86+
A module belonging to the application layer cannot be used in the Magento Framework.
87+
88+
You can build dependencies between classes in the application layer, but these classes must belong to the same module. Dependencies between the modules of the application layer should be built only by the {% glossarytooltip cdf644c4-bc99-4550-a954-dd5ae165785a %}service contract{% endglossarytooltip %} or the service provider interface (SPI).
89+
3490
## Managing module dependencies
3591

3692
At a high level, there are three main steps for managing module dependencies:
@@ -71,6 +127,3 @@ return [
71127
## Related topics {#m2arch-module-related}
72128

73129
[Module overview]({{page.baseurl}}/architecture/archi_perspectives/components/modules/mod_intro.html)
74-
75-
[Types of module dependencies]({{page.baseurl}}/architecture/archi_perspectives/components/modules/mod_depend_types.html)
76-

guides/v2.1/architecture/archi_perspectives/components/modules/mod_intro.md

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,66 @@ Modules and themes are the units of customization in Magento. Modules provide bu
1212

1313
The Magento Framework provides a set of core logic: [PHP](https://glossary.magento.com/php) code, libraries, and the basic functions that are inherited by the modules and other components.
1414

15-
## Module purpose
15+
## Purpose of a module
1616

17-
The purpose of each module is to provide specific product features by implementing new functionality or extending the functionality of other modules. Each module is designed to function independently, so the inclusion or exclusion of a particular module does not typically affect the functionality of other modules.
17+
The purpose of a module is to provide specific product features by implementing new functionality or extending the functionality of other modules. Each module is designed to function independently, so the inclusion or exclusion of a particular module does not typically affect the functionality of other modules.
1818

1919
## Module components
2020

2121
A module is a directory that contains the PHP and [XML](https://glossary.magento.com/xml) files (blocks, controllers, helpers, models) that are related to a specific business feature, such as Shipping. Specifically, a Magento module is composed of these software components: [themes]({{page.baseurl}}/frontend-dev-guide/themes/theme-overview.html), [libraries]({{page.baseurl}}/architecture/archi_perspectives/third-party-libs.html), and [language packages]({{page.baseurl}}/frontend-dev-guide/translations/xlate.html#m2devgde-xlate-languagepack).
2222

23-
## Where do modules live?
23+
## Module locations
2424

2525
Modules typically live in the `vendor` directory of a Magento installation, in a directory with the following PSR-0 compliant format: `vendor/<vendor>/<type>-<module-name>`, where `<type>` can be one of the following values:
26-
- **`module`** - for modules (`module-customer-import-export`)
27-
- **`theme`** - for frontend and admin themes (`theme-frontend-luma` or `theme-adminhtml-backend`)
28-
- **`language`** - for language packs (`language-de_de`)
26+
27+
- **`module`** - for modules (`module-customer-import-export`)
28+
- **`theme`** - for frontend and admin themes (`theme-frontend-luma` or `theme-adminhtml-backend`)
29+
- **`language`** - for language packs (`language-de_de`)
2930

3031
For example, the Customer Import/Export module of Magento can be found at `vendor/magento/module-customer-import-export`.
3132

32-
But if you are creating a new module for distribution, you can just create the `app/code/<vendor>/<type>-<module-name>` directory and the required directories within it.
33+
If you are creating a new module for distribution, create the `app/code/<vendor>/<type>-<module-name>` directory and the required directories within it.
3334

3435
Inside this folder, you will find all the code related to this module, including the `etc/module.xml` file, which contains the name and version of the module, as well as any dependencies.
3536

37+
### Module location conventions {#m2arch-module-conventions-location}
38+
39+
The following table shows the *recommended* location within the Magento file system for specific components.
40+
41+
(A {% glossarytooltip c1e4242b-1f1a-44c3-9d72-1d5b1435e142 %}module{% endglossarytooltip %} must include a `registration.php` file in its root folder.)
42+
43+
We refer to a component's root directory as the top-level directory in which you develop component code. Typically, this directory is located in one of the following directories relative to the Magento root directory:
44+
45+
|Entity|Location|
46+
|---|---|
47+
|Code base of your custom module|`/app/code/<Vendor>/<Module>`|
48+
|Custom theme files (storefront)|`/app/design/frontend/<Vendor>/<theme>`|
49+
|Custom theme files (modules)|`<Module>/<theme>`|
50+
|If you want to use a library|`/lib/<Vendor_Library>`|
51+
3652
## Working with modules
3753

3854
Magento developers, administrators, and anyone building a Magento website will want to review all relevant topics surrounding their particular goals and use cases.
3955

40-
See [PHP Developer Guide]({{page.baseurl}}/extension-dev-guide/bk-extension-dev-guide.html) for specific instructions on extending modules
41-
56+
See [PHP Developer Guide][] for specific instructions on extending modules.
4257

43-
See [Frontend Developer Guide]({{page.baseurl}}/frontend-dev-guide/bk-frontend-dev-guide.html) for information on implementing themes and other components.
58+
See [Frontend Developer Guide][] for information on implementing themes and other components.
4459

4560
## Related topics {#arch-modules-related}
4661

47-
[Module dependencies]({{page.baseurl}}/architecture/archi_perspectives/components/modules/mod_depend.html)
62+
[Module dependencies][]
4863

49-
[Modules and areas]({{page.baseurl}}/architecture/archi_perspectives/components/modules/mod_and_areas.html)
64+
[Modules and areas][]
5065

51-
[Module location and naming conventions]({{page.baseurl}}/architecture/archi_perspectives/components/modules/mod_conventions.html)
66+
[Module location and naming conventions][]
5267

68+
<!-- Link Definitions -->
69+
[Github repo]: https://github.com/magento/magento2/tree/2.3-develop/app/code/Magento
70+
[Module dependencies]: {{page.baseurl}}/architecture/archi_perspectives/components/modules/mod_depend.html
71+
[Modules and areas]: {{page.baseurl}}/architecture/archi_perspectives/components/modules/mod_and_areas.html
72+
[Module location and naming conventions]: {{page.baseurl}}/architecture/archi_perspectives/components/modules/mod_intro.html
73+
[PHP Developer Guide]: {{page.baseurl}}/extension-dev-guide/bk-extension-dev-guide.html
74+
[Frontend Developer Guide]: {{page.baseurl}}/frontend-dev-guide/bk-frontend-dev-guide.html
75+
[themes]: {{page.baseurl}}/frontend-dev-guide/themes/theme-overview.html
76+
[libraries]: {{page.baseurl}}/architecture/archi_perspectives/third-party-libs.html
77+
[language packages]: {{page.baseurl}}/frontend-dev-guide/translations/xlate.html#m2devgde-xlate-languagepack

guides/v2.1/architecture/archi_perspectives/components/modules/mod_relationships.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,4 @@ If module A replaces module B, it needs to be able to do so in such a way that o
4848

4949
## Related topics {#m2arch-module-related}
5050

51-
[Module overview]({{page.baseurl}}/architecture/archi_perspectives/components/modules/mod_intro.html)
52-
53-
51+
[Module overview]({{page.baseurl}}/architecture/archi_perspectives/components/modules/mod_intro.html)

guides/v2.1/architecture/archi_perspectives/domain_layer.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,22 @@ title: Domain layer
44
menu_title: Domain layer
55
---
66

7-
## What is Magento Domain layer?
7+
## The Magento Domain layer
88

99
The [domain](https://glossary.magento.com/domain) layer holds the business logic layer of a Magento [module](https://glossary.magento.com/module). It typically does not contain resource-specific or database-specific information. Its primary functions include:
1010

1111
* Defining the generic Magento data objects, or models, that contain business logic. This logic defines which operations can be performed on particular types of data, such as a Customer object. These models contain generic information only. Applications can also use SOAP or RESTful endpoints to request data from models.
1212

1313
* (Optionally) Including the implementation of service contracts, although not their definition.
1414

15-
1615
{:.bs-callout .bs-callout-tip}
1716
**Best practice:** Use service contracts to communicate with the domain layer by passing data types through strongly typed objects. This helps you avoid the need to replace presentation layer code when replacing business layer logic.
1817

1918
## Models
2019

2120
Each domain-layer model contains a reference to a resource model, which it uses to retrieve data from the database with MySql calls. This resource model contains logic for connecting to the underlying database, typically MySQL. A model requires a resource model only if the model data must persist.
2221

23-
## Who accesses the domain layer?
22+
## Accessing the domain layer
2423

2524
There are three primary ways of accessing a module's domain-layer code:
2625

@@ -30,11 +29,11 @@ There are three primary ways of accessing a module's domain-layer code:
3029

3130
* Domain layer code in one module can also plug itself into another module by:
3231

33-
* event hooks
32+
* event hooks
3433

35-
* plugins
34+
* plugins
3635

37-
* `di.xml` files (with an SPI contract)
36+
* `di.xml` files (with an SPI contract)
3837

3938
Your strategy for calling another module's domain-layer code is highly dependent upon the unique configuration and needs of your system.
4039

0 commit comments

Comments
 (0)