preload.php 文件在哪里,它是如何生成的?

Where is the preload.php file, and how is it generated?

使用 Symfony 5.1 和 PHP 7.4,我想在 opcache 中添加 preload.php

Symfony documentation :

During container compilation (e.g. when running the cache:clear command), Symfony generates a file called preload.php in the config/ directory with the list of classes to preload.

opcache.preload=/path/to/project/config/preload.php

但是当我执行 cache:clear 时,我在 /config/ 目录中没有 preload.php 文件。

在 google 上搜索后,this site indicates :

Now, in PhpStorm, check out the var/cache/prod/ directory... here it is: App_KernelProdContainer.preload.php.

我有这个文件。是我操作有误还是文档 symfony 不是最新的?

缓存生成时不会生成该文件,所以你可以cache:clear随便执行,它不会为你生成。如果文档这么说,那就错了。

文件被复制到相应的弹性配方中。您可以查看文件 here.

您可以通过执行以下命令查看配方创建的文件:

composer symfony:recipes symfony/framework-bundle

要自动重新安装配方,只需执行:

composer sync-recipes symfony/framework-bundle --force