0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Drupal8のカスタムモジュール作成メモ

Last updated at Posted at 2017-09-14

作ってしまえば単純だが、やっぱり苦労したので必要最低限の手順をメモ。

最低限のモジュール作成

最低限のモジュール とは、drupal8にモジュールとして認識させるレベル。特に目的の動作はない。

カスタムディレクトリの用意

まずは、モジュールのディレクトリを作成します。ディレクトリ名はスネークケース (単語の区切りを"_"で区切る) を用いる。

例えば First Module というモジュールを作成する場合には、 first_module と言うようなディレクトリを作成する。

first_module/
├

MODULE.info.ymlを作成

最低限ディレクトリと MODULE.info.yml が必要です。
MODULE の部分は、ディレクトリ名とあわせておけば良い。今回は、 first_module.info.yml とし、 first_module ディレクトリに格納する。

first_module/
├first_module.info.yml

first_module.info.ymlの中身

first_module.info.yml
name: First Module                           #モジュールの名前
type: module                                  #モジュールを作成する時はmoduleでよい。
description: 'My first custom module.'        #モジュールの説明
core: 8.x                                     #対象のDrupalのバージョン
package: My Custom Module                     #パッケージ名(任意?)

モジュールをインストールする

作成したモジュールは、Drupal本体に含まれる modules ディレクトリに設置する。ただし、提供されているモジュールと区別するため modules ディレクトリの下に custom ディレクトリを作成し、その中にモジュールを設置する。

DRUPAL/
├modules/
│├custom/
││├first_module/
│││├first_module.info.yml

上記のようにモジュールを設置すると、Drupalの管理画面より「機能拡張(/admin/modules)」に First Module が表示されるので、画面に従ってインストールを実施すれば良い。

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?