我注意到一个提交 13da5dca在 Symfony demo ,将此作为差异代码的一部分:
-include_once __DIR__.'/../var/bootstrap.php.cache';
+if (PHP_VERSION_ID < 70000) {
+ include_once __DIR__.'/../var/bootstrap.php.cache';
+}
-$kernel->loadClassCache();
+if (PHP_VERSION_ID < 70000) {
+ $kernel->loadClassCache();
+}
提交评论是:修复类重新声明的错误:不要在 PHP 7 上加载缓存文件
我知道这是一个修复提交,但我想知道为什么!所以,我怀疑这是 PHP 7 的新功能或其他功能,我想找出答案。
我找到了很多资源:
- https://github.com/symfony/symfony-standard/pull/1030
- https://github.com/symfony/demo/pull/414
- https://github.com/symfony/demo/issues/411
- https://symfony.com/doc/3.3/components/class_loader.html
但没有解释,只是如何修复它导致的错误,所有这些。 有人可以解释一下吗?
最佳答案
您可以在 this issue 中找到答案并在 this PR .
正如 Cerad 所回答的,在 PHP 7 中,不使用引导缓存会更快。
关于symfony - 为什么在 php7 的 Symfony 中不推荐使用加载类缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50986329/