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

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.

主站蜘蛛池模板: 牙克石市| 慈溪市| 玉溪市| 淮安市| 铜川市| 托克托县| 临桂县| 沿河| 灵丘县| 固原市| 南陵县| 花莲市| 谢通门县| 阿拉善盟| 凤凰县| 延吉市| 宣化县| 交城县| 宜章县| 迁西县| 华容县| 泾源县| 霸州市| 镇安县| 成武县| 南溪县| 上饶县| 应用必备| 英山县| 霍邱县| 东兰县| 余庆县| 东乡| 永康市| 余江县| 东阿县| 大连市| 满城县| 齐河县| 应城市| 梁平县|