Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 26cdd8a

Browse files
authored
Merge pull request #5097 from atwixfirster/update-component-registration
magento/devdocs#: Register libraries
2 parents 3f8dcda + ee4016f commit 26cdd8a

File tree

1 file changed

+52
-16
lines changed

1 file changed

+52
-16
lines changed

guides/v2.2/extension-dev-guide/build/component-registration.md

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,58 +11,94 @@ Each component must have a file called `registration.php` in its root directory.
1111

1212
Register modules with:
1313

14-
ComponentRegistrar::register(ComponentRegistrar::MODULE, '<VendorName_ModuleName>', __DIR__);
14+
```php
15+
ComponentRegistrar::register(ComponentRegistrar::MODULE, '<VendorName_ModuleName>', __DIR__);
16+
```
1517

1618
Here `<VendorName>` is the name of the company providing the [module](https://glossary.magento.com/module) and `<ModuleName>` is the name of the module.
1719

1820
Avoid using "Ui" for your custom module name because the <code>%Vendor%_Ui</code> notation, required when specifying paths, might cause issues.
1921

2022
### Example
21-
use Magento\Framework\Component\ComponentRegistrar;
22-
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_AdminNotification', __DIR__);
23+
24+
```php
25+
use \Magento\Framework\Component\ComponentRegistrar;
26+
27+
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_AdminNotification', __DIR__);
28+
```
2329

2430
## Register themes {#register-themes}
2531

2632
Register themes with:
2733

28-
ComponentRegistrar::register(ComponentRegistrar::THEME, '<area>/<vendor>/<theme name>', __DIR__);
34+
```php
35+
ComponentRegistrar::register(ComponentRegistrar::THEME, '<area>/<vendor>/<theme name>', __DIR__);
36+
```
2937

3038
Here `<area>` is the functional area of the module (frontend, controller, and so on.), `<vendor>` is the name of the company providing the theme, and `<theme name>` is the name of the [theme](https://glossary.magento.com/theme).
3139

3240
### Example
33-
ComponentRegistrar::register(ComponentRegistrar::THEME, 'frontend/Magento/luma', __DIR__);
3441

35-
## Register language packages {#register-lagpacks}
42+
```php
43+
use \Magento\Framework\Component\ComponentRegistrar;
44+
45+
ComponentRegistrar::register(ComponentRegistrar::THEME, 'frontend/Magento/luma', __DIR__);
46+
```
47+
48+
## Register language packages {#register-langpacks}
3649

3750
Register language packages with:
3851

39-
ComponentRegistrar::register(ComponentRegistrar::LANGUAGE, '<VendorName>_<packageName>', __DIR__);
52+
```php
53+
ComponentRegistrar::register(ComponentRegistrar::LANGUAGE, '<VendorName>_<packageName>', __DIR__);
54+
```
4055

4156
Here `<VendorName>` is the name of the company providing the package and `<packageName>` is the name of the package.
4257

4358
### Example
44-
ComponentRegistrar::register(ComponentRegistrar::LANGUAGE, 'magento_de_de', __DIR__);
59+
60+
```php
61+
use \Magento\Framework\Component\ComponentRegistrar;
62+
63+
ComponentRegistrar::register(ComponentRegistrar::LANGUAGE, 'magento_de_de', __DIR__);
64+
```
65+
66+
## Register libraries {#register-libraries}
67+
68+
Libraries should be registered using
69+
70+
```php
71+
ComponentRegistrar::register(ComponentRegistrar::LIBRARY, '<vendor>/<library_name>', __DIR__);
72+
```
73+
74+
Here `<vendor>` is the name of the company providing the library. `<library_name>` is the library name.
75+
76+
### Example
77+
78+
```php
79+
use \Magento\Framework\Component\ComponentRegistrar;
80+
81+
ComponentRegistrar::register(ComponentRegistrar::LIBRARY, 'magento/framework', __DIR__);
82+
```
4583

4684
## Invoke `registration.php` in `composer.json` with autoload {#register-autoload}
4785

4886
After you create your `registration.php` file and you are creating [your component's composer.json file]({{page.baseurl}}/extension-dev-guide/build/composer-integration.html), invoke your `registration.php` file in the `autoload` section of `composer.json`:
4987

5088
```json
5189
{
52-
"name": "Acme-vendor/bar-component",
53-
"autoload": {
54-
"psr-4": { "AcmeVendor\\BarComponent\\": "" },
55-
"files": [ "registration.php" ]
56-
}
90+
"name": "Acme-vendor/bar-component",
91+
"autoload": {
92+
"psr-4": { "AcmeVendor\\BarComponent\\": "" },
93+
"files": [ "registration.php" ]
94+
}
5795
}
5896
```
5997

6098
### Sample `registration.php` file {#register-sample}
6199

62100
```php
63-
<?php
64-
65-
use Magento\Framework\Component\ComponentRegistrar;
101+
use \Magento\Framework\Component\ComponentRegistrar;
66102

67103
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_AdminNotification', __DIR__);
68104
```

0 commit comments

Comments
 (0)