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

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.

主站蜘蛛池模板: 陆河县| 临西县| 桑植县| 思茅市| 团风县| 徐州市| 晋中市| 南部县| 灌南县| 南部县| 酒泉市| 万安县| 沾益县| 大安市| 玉门市| 疏附县| 铜陵市| 平顶山市| 西和县| 义乌市| 舞钢市| 都江堰市| 阜新| 青铜峡市| 志丹县| 明水县| 庐江县| 肇源县| 正蓝旗| 长治县| 陵川县| 疏附县| 水城县| 丹凤县| 于田县| 古田县| 黄骅市| 桦甸市| 阿合奇县| 壤塘县| 阳信县|