Opcache preloader in php 7.4 on BitrixVM
Opcache preloader в php 7.4 на BitrixVM

All English-language materials have been translated fully automatically using the Google service

Preload files and classes using opcache.preloader in php 7.4+

In php, starting from version 7.4, it became possible to preload project files into memory. This can potentially significantly speed up access to them from project files. It works like this:

1. You write a file in which you list all the necessary files for preloading
2. Add the opcache.preload option to the php.ini file
3. Restart the httpd service
4. You work with files and classes preloaded into memory
5. Take into account that after making changes to files and classes, to update them in memory - the httpd service must be restarted.

In its simplest form, the listing of the preloader.php file will look like this:

require_once __DIR__.'/local/PATH_TO_VENDOR/vendor/autoload.php';
require_once __DIR__.'/local/PATH_TO_CUSTOM_CLASSES/include/autoload.php';

// File list
$files = [

// Preload all root project files
foreach ($files as $file) {
	require_once $file;

Assuming that opcache is already installed on your server and you have root access to it, then go to the file /etc/php.d/10-opcache.ini and add commands:

; Root User name. On BitrixVM it is usually root
; Full path to your preloader file

Full listing opcache.ini


Restart httpd service with command

service httpd restart

And remember it - you will need it to apply changes to the preloaded classes

If you did everything correctly, then you can see that preloading works with the command:


It will print an array of all files and classes that were preloaded


There are no comments yet, you can be the first to leave it

Leave a comment

The site uses a comment pre-moderation system, so your message will be published only after approval by the moderator

You are replying to a user's comment



Email me

Are you developing a new service, making improvements to the existing one and want to be better than your competitors? You have come to the right place. I offer you a comprehensive studio-level website development. From me you can order design, layout, programming, development of non-traditional functionality, implementation of communication between CMS, CRM and Data Analitics, as well as everything else related to sites, except for promotion.

Contact, I will always advise on all questions and help you find the most effective solution for your business. I am engaged in the creation of sites in Novosibirsk and in other regions of Russia, I also work with the CIS countries. You will be satisfied with our cooperation

An error occurred while sending, please try again after a while
Message sent successfully


+7(993) 007-18-96




Россия, г. Москва

By submitting the form, you automatically confirm that you have read and accept the Privacy Policy site

Contact with me
Send message
By submitting the form, you automatically confirm that you have read and accept Privacy policy of site
Sending successful!
Thank you for contacting :) I will contact you as soon as possible
Sending failed
An error occurred while sending the request. Please wait and try again after a while or call my phone number