当我想启用 web profiler 工具栏时,Symfony2 在开发者模式下触发大量 404:
GET http://www.domain.dev/_wdt/de040c 404 (Not Found)
所以我调试了 ProfilerController 并发现当在文件系统中找不到配置文件数据时它会触发 404。
但是对于页面的每个请求都会在“app/cache/dev/profiler”目录下创建新目录,但仍然没有文件。
app/cache/dev 下的文件树如下所示:
如您所见,目录“profiler”包含一些目录(并且它会随着对站点的每个请求而增长),但从来没有任何文件。 nginx 和 php 进程有完整的写入权限,我还配置了缓存目录作为示例,以使用/dev/shm 下的共享内存来防止对我的主机系统产生副作用(我正在使用 vagrant 进行开发)
所以我的问题是:为什么没有创建分析器数据,“谁”将对此负责?
更新:
我发现,在 FileProfileStorage.php 中,所有配置文件数据都将被收集和序列化:
// Store profile
$data = array(
'token' => $profile->getToken(),
'parent' => $profile->getParentToken(),
'children' => array_map(function ($p) { return $p->getToken(); }, $profile->getChildren()),
'data' => $profile->getCollectors(),
'ip' => $profile->getIp(),
'method' => $profile->getMethod(),
'url' => $profile->getUrl(),
'time' => $profile->getTime(),
);
if (false === file_put_contents($file, serialize($data))) {
return false;
}
这里会抛出异常“Serialization of Closure is not allowed”。我仍然没有找到哪个 DataCollector 将负责使用闭包而不是“真实”数据。
更新 2:
我发现 TwigCacheBundle 的 ProfilerExtension 会在这里抛出异常(“不支持闭包序列化”)
最佳答案
自己解决了。 TwigCacheBundle 的 ProfilerExtension 在为 Web Profiler 序列化其数据时引发异常。
我做了一个 pull request for that .
关于php - _wdt : Symfony WebProfiler doesn't generate any profile data 上的 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32923216/