【发布时间】:2016-07-11 13:47:48
【问题描述】:
我有一个名为 FilterInput 的 PHP 类。当我基于 Symfony (3.0.3) 的应用程序调用 FilterInput 的静态成员函数时,会隐式调用 Symfony 的 DebugClassLoader。该方法称为loadClass,它的开头是这样的:
public function loadClass($class)
{
ErrorHandler::stackErrors();
try {
if ($this->isFinder) {
if ($file = $this->classLoader[0]->findFile($class)) {
require_once $file;
}
} else {
call_user_func($this->classLoader, $class);
$file = false;
}
} finally {
ErrorHandler::unstackErrors();
}
...
我观察到的问题是,当执行到达include_once 指令时,应用程序会静默失败。也就是说,http 请求返回空,dev.log 或我的 apache 日志中没有输出。我已验证$file 变量包含完整且正确的/path/to/FilterInput.php。我还验证了这个文件是可读的。所以我的问题是:
- 为什么此时会停止执行?
- 为什么它会静默失败,没有日志错误消息或在响应中返回数据。
编辑:更多信息:如果我填写垃圾路径,例如"/foo/bar" 然后我收到一条错误消息Compile Error: AppBundle\Components\Factory::getDBO(): Failed opening required '/foo/bar' (include_path='.:');所以推测无声失败与在给定路径下有一个文件的事实有关。
【问题讨论】:
-
您确定处于开发模式吗?在您的 app.php 中,确保您像这样实例化您的 AppKernel:
$kernel = new AppKernel('dev', true); -
这帮助我找到了很多以前被忽略的错误 - 但我仍然在 require_once 时遇到 silent 失败