我已经安装了Magento 2并且它正在工作。我刚刚创建了Hello world模块,它现在也在工作。
我的问题是,在execute方法中调用了不存在的方法。
当我尝试加载页面时,它显示一个空白白屏,但没有错误信息。
如何在Magento 2中显示错误信息?
我已经安装了Magento 2并且它正在工作。我刚刚创建了Hello world模块,它现在也在工作。
我的问题是,在execute方法中调用了不存在的方法。
当我尝试加载页面时,它显示一个空白白屏,但没有错误信息。
如何在Magento 2中显示错误信息?
error_reporting(E_ALL);
ini_set('display_errors', 1);
app/bootstrap.php
中作为一行注释的代码。也可以在那里删除注释... - feeelaphp.ini
文件。如果 error_reporting
或 display_errors
被关闭了,您应该在那里进行修复,而不是在 bootstrap.php
中进行修复。否则,您最终会在生产环境中显示错误,并可能泄漏敏感数据。 - stollrphp bin/magento deploy:mode:set developer
这将在您的Magento实例下启用开发者模式,对于生产模式,您可以将模式设置为“生产”或“默认”。
如果仍然遇到错误报告问题,
您可以尝试将pub/errors下的local.xml.sample重命名为local.xml
这是一个适合这种情况的地方。在bootstrap.php
文件中,有以下代码:
#ini_set('display_errors', 1);
只需将其注释取消。
1) app/bootstrap.php,其中有:
#ini_set('display_errors', 1);
请取消注释。
2) 运行以下命令
php bin/magento deploy:mode:set developer
php bin/magento cache:clean
php bin/magento cache:flush
php bin/magento cache:clean
is a subset of php bin/magento cache:flush
, in other workds you only need run the cache:flush
- Barry要检查当前模式,请使用:
bin/magento deploy:mode:show
除了编辑index.php
或app/bootstrap.php
文件外,您还可以编辑.htaccess
文件以启用PHP显示错误设置。
在Magento2网站根目录中的.htaccess
文件末尾编写以下代码行:
## enable PHP's error display settings
php_value display_errors on
## set error display to E_ALL
php_value error_reporting -1
Go to your Magento's root directory
cd /path/to/your/magento/root/folder
Run the following command to enable developer mode:
php bin/magento deploy:mode:set developer
To check your current developer mode, you can run the command:
php bin/magento deploy:mode:show
ini_set('error_reporting', E_ERROR);
register_shutdown_function("fatal_handler");
function fatal_handler() {
$error = error_get_last();
echo("<pre>");
print_r($error);
}
php bin/magento deploy:mode:set developer
启用开发者模式,如此处所示。 - Steve Johnson~/
的子文件夹中。 - Krista K