krifollk / module-code-generator
magento 2 的代码生成器
v0.4.0
2017-07-15 19:18 UTC
Requires
- php: ~7.0
This package is auto-updated.
Last update: 2024-09-21 19:40:17 UTC
README
此模块提供通过命令行工具生成代码的可能性。
要求
- magento 2 (CE, EE) 2.1.0 及以上版本
- PHP >=7.0
安装
使用以下命令安装最新版本:
$ composer require krifollk/module-code-generator
使用方法
目前,模块支持以下命令:
生成模块骨架。
- 第一个参数是模块名称。
- 第二个参数是模块版本(不是必需的,默认为0.1.0)。
$ php bin/magento generate:module Config_Editor 0.2.0 Output: File /var/www/magento2/app/code/Config/Editor/registration.php was generated. File /var/www/magento2/app/code/Config/Editor/etc/module.xml was generated. File /var/www/magento2/app/code/Config/Editor/composer.json was generated. File /var/www/magento2/app/code/Config/Editor/Setup/InstallData.php was generated. File /var/www/magento2/app/code/Config/Editor/Setup/InstallSchema.php was generated. File /var/www/magento2/app/code/Config/Editor/Setup/Uninstall.php was generated. File /var/www/magento2/app/code/Config/Editor/Setup/UpgradeData.php was generated. File /var/www/magento2/app/code/Config/Editor/Setup/UpgradeSchema.php was generated.
通过数据库表生成“模型三合一”。
- 第一个参数是模块名称。
- 第二个参数是实体名称。
- 第三个参数是表名称。
$ php bin/magento generate:model:triad Config_Editor Config core_config_data Output: File /var/www/magento2/app/code/Config/Editor/Api/Data/ConfigInterface.php was generated. File /var/www/magento2/app/code/Config/Editor/Model/ResourceModel/Config.php was generated. File /var/www/magento2/app/code/Config/Editor/Model/Config.php was generated. File /var/www/magento2/app/code/Config/Editor/Model/ResourceModel/Config/Collection.php was generated. File /var/www/magento2/app/code/Config/Editor/Api/Data/ConfigSearchResultsInterface.php was generated. File /var/www/magento2/app/code/Config/Editor/Api/ConfigRepositoryInterface.php was generated. File /var/www/magento2/app/code/Config/Editor/Model/ConfigRepository.php was generated. File /var/www/magento2/app/code/Config/Editor/etc/di.xml was generated.
通过数据库表生成“CRUD”。
- 第一个参数是模块名称。
- 第二个参数是实体名称。
- 第三个参数是表名称。
$ php bin/magento generate:crud Config_Editor Config core_config_data Output: File /var/www/magento2/app/code/Config/Editor/Api/Data/ConfigInterface.php was generated. File /var/www/magento2/app/code/Config/Editor/Model/ResourceModel/Config.php was generated. File /var/www/magento2/app/code/Config/Editor/Model/Config.php was generated. File /var/www/magento2/app/code/Config/Editor/Model/ResourceModel/Config/Collection.php was generated. File /var/www/magento2/app/code/Config/Editor/Api/Data/ConfigSearchResultsInterface.php was generated. File /var/www/magento2/app/code/Config/Editor/Api/ConfigRepositoryInterface.php was generated. File /var/www/magento2/app/code/Config/Editor/Model/ConfigRepository.php was generated. File /var/www/magento2/app/code/Config/Editor/etc/di.xml was generated. File /var/www/magento2/app/code/Config/Editor/Model/UiComponent/Listing/Column/ConfigActions.php was generated. File /var/www/magento2/app/code/Config/Editor/Model/Config/DataProvider.php was generated. File /var/www/magento2/app/code/Config/Editor/Model/ResourceModel/Config/Grid/Collection.php was generated. File /var/www/magento2/app/code/Config/Editor/view/adminhtml/ui_component/config_editor_config_form.xml was generated. File /var/www/magento2/app/code/Config/Editor/view/adminhtml/ui_component/config_editor_config_listing.xml was generated. File /var/www/magento2/app/code/Config/Editor/view/adminhtml/layout/config_editor_config_edit.xml was generated. File /var/www/magento2/app/code/Config/Editor/view/adminhtml/layout/config_editor_config_index.xml was generated. File /var/www/magento2/app/code/Config/Editor/view/adminhtml/layout/config_editor_config_new.xml was generated. File /var/www/magento2/app/code/Config/Editor/Controller/Adminhtml/Config/Index.php was generated. File /var/www/magento2/app/code/Config/Editor/etc/adminhtml/routes.xml was generated. File /var/www/magento2/app/code/Config/Editor/etc/di.xml was generated. File /var/www/magento2/app/code/Config/Editor/Controller/Adminhtml/Config/Edit.php was generated. File /var/www/magento2/app/code/Config/Editor/Controller/Adminhtml/Config/NewAction.php was generated. File /var/www/magento2/app/code/Config/Editor/Controller/Adminhtml/Config/Save.php was generated. File /var/www/magento2/app/code/Config/Editor/Controller/Adminhtml/Config/Delete.php was generated. File /var/www/magento2/app/code/Config/Editor/Controller/Adminhtml/Config/MassDelete.php was generated. File /var/www/magento2/app/code/Config/Editor/Controller/Adminhtml/Config/InlineEdit.php was generated.
生成“插件”(交互模式)
- 第一个参数是模块名称。
$ php bin/magento generate:plugin Config_Editor Output: Enter the name of the class for which you want to create plugin: \Magento\Cms\Controller\Index\Index Enter the name of the plugin class (\Module\Name\ part not required) Default: \Config\Editor\Plugin\Magento\Cms\Controller\Index\Index: +-----+-----------------+ | #id | Allowed methods | +-----+-----------------+ | 0 | execute | | 1 | dispatch | | 2 | getActionFlag | | 3 | getRequest | | 4 | getResponse | +-----+-----------------+ Enter method ids and types of interception(a - after, b - before, ar - around) for which you want to create plugin using next format: id:b-ar-a, id:a-b: 0:a-b-ar +-------------+--------------------+ | Method Name | Interception types | +-------------+--------------------+ | execute | Before | | | Around | | | After | | | | +-------------+--------------------+ Is everything alright ? (y\n - yes by default) File /var/www/magento2/app/code/Config/Editor/Plugin/Magento/Cms/Controller/Index/Index.php has been generated. File /var/www/magento2/app/code/Config/Editor/etc/di.xml has been generated.
此外,所有命令都支持--dir选项,您可以指定自定义的模块目录。
例如:--dir=modules/module-some-dir
提交错误和功能请求
错误和功能请求在GitHub上跟踪
作者
Rostyslav Tymoshenko
许可证
此项目采用MIT许可证 - 请参阅LICENSE文件以获取详细信息