官术网_书友最值得收藏!

Namespaces

Before moving on with the Controller we set out to write, let's break down the namespace situation in Drupal 8 and how the folder structure needs to be inside a module.

Drupal 8 uses the PSR-4 namespace autoloading standard. In effect, this means that the namespace of all Drupal core and module classes starts with \Drupal. For modules, the base namespace is \Drupal\module_name, where module_name is the machine name of the module. This then maps to the /src folder found inside the module directory (for main integration files). For PHPUnit tests, we have a different namespace, as we will see later in the book.

So essentially, we will need a /src folder inside our module to place all of our classes that need to be autoloaded. So, we can go ahead and create it.

主站蜘蛛池模板: 平顺县| 达尔| 修水县| 泽普县| 邯郸市| 大荔县| 奉节县| 仁怀市| 义乌市| 阿克苏市| 红桥区| 平乐县| 南乐县| 碌曲县| 涪陵区| 鄢陵县| 泰安市| 邵武市| 定州市| 阿瓦提县| 泾阳县| 怀仁县| 澎湖县| 永昌县| 阿尔山市| 中江县| 东乡| 突泉县| 闻喜县| 怀仁县| 遂川县| 桂阳县| 白朗县| 五家渠市| 万山特区| 扶绥县| 扶风县| 西乌珠穆沁旗| 乐清市| 巫山县| 鹤峰县|