Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 未执行Magento 2 InstallSchema_Php_Magento_Magento2 - Fatal编程技术网

Php 未执行Magento 2 InstallSchema

Php 未执行Magento 2 InstallSchema,php,magento,magento2,Php,Magento,Magento2,我已经编写了一个基本的Magento 2自定义模块。当我运行bin/Magento module:enable时,模块能够注册到Magento 2。我已经检查了设置\u模块表,模块条目在那里,模块已启用 我在运行Setup/InstallSchema.php时遇到问题。不管我做什么,模式安装程序永远不会执行。我假设这是因为当我第一次执行bin/magento setup:upgrade命令时,我有一个空白的InstallSchema.php。禁用和重新启用模块没有任何作用。我已经检查了数据库,M

我已经编写了一个基本的Magento 2自定义模块。当我运行
bin/Magento module:enable
时,模块能够注册到Magento 2。我已经检查了
设置\u模块
表,模块条目在那里,模块已启用

我在运行
Setup/InstallSchema.php
时遇到问题。不管我做什么,模式安装程序永远不会执行。我假设这是因为当我第一次执行
bin/magento setup:upgrade
命令时,我有一个空白的
InstallSchema.php
。禁用和重新启用模块没有任何作用。我已经检查了数据库,Magento似乎没有使用数据库跟踪模块
设置\u版本
。我试着在磁盘上找到Magento跟踪当前安装的
setup\u版本的位置
,但到目前为止我画了一个空白。我知道Magento可以调用我的模块,因为它正在非常愉快地执行
Setup/InstallData.php
文件


有人知道如何强制Magento 2执行我的
Setup/InstallSchema.php
文件吗?

你说得对,Magento在执行
bin/Magento Setup:upgrade
命令时执行
InstallSchema
一次。您可以为安装后的更改创建一个
UpgradeSchema

按照以下步骤将InstallSchema转换为UpgradeSchema

1) 复制当前的
InstallSchema
文件,并将其重命名为
UpgradeSchema

2) 编辑
UpgradeSchema.php
并找到replace:-

{ InstallSchema } => { UpgradeSchema }

 { public function install } => { public function upgrade }
3) 将
/app/code/vender/module/etc/module.xml中的
setup\u version=“1.0.0”
更改为
setup\u version=“1.0.1”

4) 执行
php bin/magento设置:升级


希望它能起作用……)

我认为,如果您从
setup\u module
表中删除与模块名称匹配的行,那么它应该运行
InstallSchema
。还要确保setup\InstallSchema.php中的名称空间是正确的