YAML files are the newly introduced important project files, and in Drupal 8, whether it's a module, a theme, or a setup profile, you'll need a. info.yml file to store the underlying information about the project.
In Drupal,. info.yml files are typically used for the following purposes:
- Declaring the existence of modules, themes, installation profiles to Drupal
- Providing information to the Drupal Web management interface
- Provides module start, disable conditions, and version compatibility information
- Other management uses
Hello World Example
Here is a simple hello_world.info.yml file, you can create a new Hello_world directory under the Local module directory (/modules/custom or/sites/all/modules/custom), and will contain the contents below to The hello_world.info.yml file is placed in the module directory:
name: Hellow World Module
description: Creates a page showing “Hello World”
package: Example
type: module
core: 8.x
- The first three lines of information in the code are used in the module management interface, which is visible to users when they enable or disable the module. Where name and description are required , each represents the name and description of the module.
- The package is optional to set the grouping information for the module.
- Type is a new "required" message in Drupal 8 that declares the type of project, such as module, theme or profile (modules, themes, or installation configuration packages)
- The core is used to set the version information of the Drupal kernel so that Drupal confirms the version of Drupal that this project is compatible with.
Complete example
In addition to the property settings in the example above, the project information file contains some other optional properties, which can be referenced in the following code:
name: Hello World Module
description: Creates a page showing "Hello World".
package: Custom
type: module
core: 8.x
dependencies:
- datetime
- link
- views
configure: hello_world.settings
hidden: true
# Note: do not add the ‘version‘ property yourself!
# It will be added automatically by the packager on drupal.org.
version: 1.0
The configuration items in the Yaml file are semantically sufficient to literally understand their meaning. If you've had Drupal-related development experience, it's easier to understand the YAML configuration files in Drupal 8.
Original title: Drupal8 Development Tutorial: Understanding. info.yml File
Original address: http://drupalct.org/drupal-development/learn-drupal8-info-yaml-file.html
Drupal8 Development Tutorial: Understanding. info.yml Files