Skip to content
Advertisement

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

With Symfony 5.1 and PHP 7.4, I want to add preload.php in opcache.

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

But when I execute cache:clear, I don’t have preload.php file in /config/ directory.

After search on google, this site indicates :

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

I have this file. Did I perform something wrong or is the documentation symfony not up to date ?

Advertisement

Answer

The file is not generated during cache generation, so you can execute cache:clear all you want and it won’t be generated for you. If the documentation says so, it’s wrong.

The file is copied in the corresponding flex recipe. You can check the file here.

You can check the files created by the recipe by executing:

composer symfony:recipes symfony/framework-bundle

To reinstall the recipe automatically, just execute:

composer sync-recipes symfony/framework-bundle --force
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement