Magento2でエクステンションを作成する
今回からニュース一覧を表示するエクステンションを作成していきます。今回はエクステンションの作成と有効化までです。
エクステンションを作成する
準備として以下のファイルを作成します。(作成するエクステンション名はVendor_Newsです。)
- magento/app/code/Vendor/News/etc/module.xml
- magento/app/code/Vendor/News/registration.php
magento/
└ app/
└ code/
└ Vendor/
└ News/
├ etc/
│ └ module.xml
└ registration.php
作成したファイルにエクステンションの雛形を記述します。エクステンション名以外は全て共有です。
module.xml
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vendor_News" setup_version="1.0.0"/>
</config>
registration.php
<?php
Magento\Framework\Component\ComponentRegistrar::register(
Magento\Framework\Component\ComponentRegistrar::MODULE,
'Vendor_News',
__DIR__
);
エクステンションを有効化する
ここまででMagentoがエクステンションとして認識するようになりました。確認してみましょう。
$ php bin/magento module:status
List of disabled modules:
Vendor_News
このように表示されれば認識されています。それではエクステンションを有効化します。
$ php bin/magento module:enable Vendor_News
エクステンションの作成と有効化は以上です。
Author And Source
この問題について(Magento2でエクステンションを作成する), 我々は、より多くの情報をここで見つけました https://qiita.com/rtakabe/items/3935d499f3a10641b9ee著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .