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

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 is 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.

主站蜘蛛池模板: 江门市| 东港市| 四子王旗| 莱阳市| 桃源县| 交城县| 佛坪县| 弥渡县| 富顺县| 浮梁县| 闽清县| 定日县| 丹江口市| 木里| 普定县| 桐庐县| 康保县| 外汇| 莱芜市| 额尔古纳市| 茂名市| 缙云县| 海淀区| 苍梧县| 本溪| 大同县| 增城市| 德格县| 宣威市| 余姚市| 大安市| 峨眉山市| 东山县| 永昌县| 阿坝县| 徐水县| 北宁市| 星子县| 大荔县| 海门市| 博爱县|