Php Magento编译器-命令行
当我通过命令行在 我的存储,它返回编译器已启用,以便在管理中,但当我检查我的Magento站点的根文件夹中是否为return时,状态为disabled $/var/www/magento# php shell/compiler.php state Compiler Status: Disabled Compilation State: Compiled Collected Files Count: 6764 Compiled Scopes Count: 4 $/var/www/magento# cd shell/ $/var/www/magento/shell# php compiler.php state Compiler Status: Enabled Compilation State: Compiled Collected Files Count: 6764 Compiled Scopes Count: 4 $/var/www/magento#php shell/compiler.php state 编译器状态:已禁用 编译状态:已编译 收集的档案数目:6764 已编译作用域计数:4 $/var/www/magento#cd shell/ $/var/www/magento/shell#php compiler.php state 编译器状态:已启用 编译状态:已编译 收集的档案数目:6764 已编译作用域计数:4Php Magento编译器-命令行,php,magento,command-line,compiler-construction,Php,Magento,Command Line,Compiler Construction,当我通过命令行在 我的存储,它返回编译器已启用,以便在管理中,但当我检查我的Magento站点的根文件夹中是否为return时,状态为disabled $/var/www/magento# php shell/compiler.php state Compiler Status: Disabled Compilation State: Compiled Collected Files Count: 6764 Compiled Scopes Count:
虽然我试图通过关闭编译器模式,重新编译,然后再打开来修复这个问题,但我得到了相同的结果 编辑
includes/config.php
并注释掉两行define
。这就是Magento启用/禁用编译器所做的一切
shell/compiler.php
$compiler = $this->_getCompiler();
$compilerConfig = '../includes/config.php';
if (file_exists($compilerConfig)) {
include $compilerConfig;
}
$status = defined('COMPILER_INCLUDE_PATH') ? 'Enabled' : 'Disabled';
此外,我建议只使用或任何其他操作码缓存,因为它可以解决同样的问题,而且不会让人头痛。这“按设计工作”(只是设计不好)。下面是compiler.php
中确定状态的代码位
$compilerConfig = '../includes/config.php';
if (file_exists($compilerConfig)) {
include $compilerConfig;
}
$status = defined('COMPILER_INCLUDE_PATH') ? 'Enabled' : 'Disabl ed';
关键行是$compilerConfig='../includes/config.php'代码>。此路径从当前目录向上移动一个目录,以查找config.php
。PHP shell脚本的工作目录是从中调用的,而不是它所在的目录。你这么说
$/var/www/magento# php shell/compiler.php state
脚本在中查找文件
/var/www/magento/../includes/config.php
或
因为找不到,所以它假设状态为disabled。我意识到这是一篇旧文章,但在Magento 1.9中似乎仍然存在此错误。
如果希望能够从其他目录检查编译器状态,只需修改此行:
$compilerConfig = '../includes/config.php';
改为
$compilerConfig = dirname(__FILE__).'/../includes/config.php';
我看不出这两个答案之间有什么区别,但这很公平
$compilerConfig = dirname(__FILE__).'/../includes/config.php';