Runtime Configuration

The behaviour of these functions is affected by settings in php.ini.

OPcache configuration options
Name Default Changeable Changelog
opcache.enable "1" PHP_INI_ALL  
opcache.enable_cli "0" PHP_INI_SYSTEM Between PHP 7.1.2 and 7.1.6 inclusive, the default was "1"
opcache.memory_consumption "128" PHP_INI_SYSTEM  
opcache.interned_strings_buffer "8" PHP_INI_SYSTEM  
opcache.max_accelerated_files "10000" PHP_INI_SYSTEM  
opcache.max_wasted_percentage "5" PHP_INI_SYSTEM  
opcache.use_cwd "1" PHP_INI_SYSTEM  
opcache.validate_timestamps "1" PHP_INI_ALL  
opcache.revalidate_freq "2" PHP_INI_ALL  
opcache.revalidate_path "0" PHP_INI_ALL  
opcache.save_comments "1" PHP_INI_SYSTEM  
opcache.fast_shutdown "0" PHP_INI_SYSTEM Removed in PHP 7.2.0
opcache.enable_file_override "0" PHP_INI_SYSTEM  
opcache.optimization_level "0x7FFEBFFF" PHP_INI_SYSTEM Changed from 0x7FFFBFFF in PHP 7.3.0
opcache.inherited_hack "1" PHP_INI_SYSTEM Removed in PHP 7.3.0
opcache.dups_fix "0" PHP_INI_ALL  
opcache.blacklist_filename "" PHP_INI_SYSTEM  
opcache.max_file_size "0" PHP_INI_SYSTEM  
opcache.consistency_checks "0" PHP_INI_ALL  
opcache.force_restart_timeout "180" PHP_INI_SYSTEM  
opcache.error_log "" PHP_INI_SYSTEM  
opcache.log_verbosity_level "1" PHP_INI_SYSTEM  
opcache.record_warnings "0" PHP_INI_SYSTEM Available as of PHP 8.0.0
opcache.preferred_memory_model "" PHP_INI_SYSTEM  
opcache.protect_memory "0" PHP_INI_SYSTEM  
opcache.mmap_base null PHP_INI_SYSTEM  
opcache.restrict_api "" PHP_INI_SYSTEM  
opcache.file_update_protection "2" PHP_INI_ALL  
opcache.huge_code_pages "0" PHP_INI_SYSTEM  
opcache.lockfile_path "/tmp" PHP_INI_SYSTEM  
opcache.opt_debug_level "0" PHP_INI_SYSTEM Available as of PHP 7.1.0
opcache.file_cache NULL PHP_INI_SYSTEM  
opcache.file_cache_only "0" PHP_INI_SYSTEM  
opcache.file_cache_consistency_checks "1" PHP_INI_SYSTEM  
opcache.file_cache_fallback "1" PHP_INI_SYSTEM Windows only.
opcache.validate_permission "0" PHP_INI_SYSTEM Available as of PHP 7.0.14
opcache.validate_root "0" PHP_INI_SYSTEM Available as of PHP 7.0.14
opcache.preload "" PHP_INI_SYSTEM Available as of PHP 7.4.0
opcache.preload_user "" PHP_INI_SYSTEM Available as of PHP 7.4.0
opcache.cache_id "" PHP_INI_SYSTEM Windows only. Available as of PHP 7.4.0
opcache.jit "tracing" PHP_INI_ALL Available as of PHP 8.0.0
opcache.jit_buffer_size "0" PHP_INI_SYSTEM Available as of PHP 8.0.0
opcache.jit_debug "0" PHP_INI_ALL Available as of PHP 8.0.0
opcache.jit_bisect_limit "0" PHP_INI_ALL Available as of PHP 8.0.0
opcache.jit_prof_threshold "0.005" PHP_INI_ALL Available as of PHP 8.0.0
opcache.jit_max_root_traces "1024" PHP_INI_SYSTEM Available as of PHP 8.0.0
opcache.jit_max_side_traces "128" PHP_INI_SYSTEM Available as of PHP 8.0.0
opcache.jit_max_exit_counters "8192" PHP_INI_SYSTEM Available as of PHP 8.0.0
opcache.jit_hot_loop "64" PHP_INI_SYSTEM Available as of PHP 8.0.0
opcache.jit_hot_func "127" PHP_INI_SYSTEM Available as of PHP 8.0.0
opcache.jit_hot_return "8" PHP_INI_SYSTEM Available as of PHP 8.0.0
opcache.jit_hot_side_exit "8" PHP_INI_SYSTEM Available as of PHP 8.0.0
opcache.jit_blacklist_root_trace "16" PHP_INI_ALL Available as of PHP 8.0.0
opcache.jit_blacklist_side_trace "8" PHP_INI_ALL Available as of PHP 8.0.0
opcache.jit_max_loop_unrolls "8" PHP_INI_ALL Available as of PHP 8.0.0
opcache.jit_max_recursive_calls "2" PHP_INI_ALL Available as of PHP 8.0.0
opcache.jit_max_recursive_returns "2" PHP_INI_ALL Available as of PHP 8.0.0
opcache.jit_max_polymorphic_calls "2" PHP_INI_ALL Available as of PHP 8.0.0
For further details and definitions of the PHP_INI_* modes, see the Where a configuration setting may be set.

Here's a short explanation of the configuration directives.

opcache.enable bool

Enables the opcode cache. When disabled, code is not optimised or cached. The setting opcache.enable can not be enabled at runtime through ini_set(), it can only be disabled. Trying to enable it in a script will generate a warning.

opcache.enable_cli bool

Enables the opcode cache for the CLI version of PHP.

opcache.memory_consumption int

The size of the shared memory storage used by OPcache, in megabytes. The minimum permissible value is "8", which is enforced if a smaller value is set.

opcache.interned_strings_buffer int

The amount of memory used to store interned strings, in megabytes.

opcache.max_accelerated_files int

The maximum number of keys (and therefore scripts) in the OPcache hash table. The actual value used will be the first number in the set of prime numbers { 223, 463, 983, 1979, 3907, 7963, 16229, 32531, 65407, 130987, 262237, 524521, 1048793 } that is greater than or equal to the configured value. The minimum value is 200. The maximum value is 1000000. Values outside of this range are clamped to the permissible range.

opcache.max_wasted_percentage int

The maximum percentage of wasted memory that is allowed before a restart is scheduled, if there is insufficient free memory. The maximum permissible value is "50", which is enforced if a larger value is set.

opcache.use_cwd bool

If enabled, OPcache appends the current working directory to the script key, thereby eliminating possible collisions between files with the same base name. Disabling this directive improves performance, but may break existing applications.

opcache.validate_timestamps bool

If enabled, OPcache will check for updated scripts every opcache.revalidate_freq seconds. When this directive is disabled, you must reset OPcache manually via opcache_reset(), opcache_invalidate() or by restarting the Web server for changes to the filesystem to take effect.

opcache.revalidate_freq int

How often to check script timestamps for updates, in seconds. 0 will result in OPcache checking for updates on every request.

This configuration directive is ignored if opcache.validate_timestamps is disabled.

opcache.revalidate_path bool

If disabled, existing cached files using the same include_path will be reused. Thus, if a file with the same name is elsewhere in the include_path, it won't be found.

opcache.save_comments bool

If disabled, all documentation comments will be discarded from the opcode cache to reduce the size of the optimised code. Disabling this configuration directive may break applications and frameworks that rely on comment parsing for annotations, including Doctrine, Zend Framework 2 and PHPUnit.

opcache.fast_shutdown bool

If enabled, a fast shutdown sequence is used that doesn't free each allocated block, but relies on the Zend Engine memory manager to deallocate the entire set of request variables en masse.

This directive has been removed in PHP 7.2.0. A variant of the fast shutdown sequence has been integrated into PHP and will be automatically used if possible.

opcache.enable_file_override bool

When enabled, the opcode cache will be checked for whether a file has already been cached when file_exists(), is_file() and is_readable() are called. This may increase performance in applications that check the existence and readability of PHP scripts, but risks returning stale data if opcache.validate_timestamps is disabled.

opcache.optimization_level int

A bitmask that controls which optimisation passes are executed. The default is to apply all safe optimizations. Changing the default is mostly useful for debugging/developing the optimizer (see also opcache.opt_debug_level).

opcache.inherited_hack bool

This configuration directive is ignored.

opcache.dups_fix bool

This hack should only be enabled to work around "Cannot redeclare class" errors.

opcache.blacklist_filename string

The location of the OPcache blacklist file. A blacklist file is a text file containing the names of files that should not be accelerated, one per line. Wildcards are allowed, and prefixes can also be provided. Lines starting with a semi-colon are ignored as comments.

A simple blacklist file might look as follows:

; Matches a specific file.
/var/www/broken.php
; A prefix that matches all files starting with x.
/var/www/x
; A wildcard match.
/var/www/*-broken.php
opcache.max_file_size int

The maximum file size that will be cached, in bytes. If this is 0, all files will be cached.

opcache.consistency_checks int

If non-zero, OPcache will verify the cache checksum every N requests, where N is the value of this configuration directive. This should only be enabled when debugging, as it will impair performance.

opcache.force_restart_timeout int

The length of time to wait for a scheduled restart to begin if the cache isn't active, in seconds. If the timeout is hit, then OPcache assumes that something is wrong and will kill the processes holding locks on the cache to permit a restart.

If opcache.log_verbosity_level is set to 2 or above, a warning will be recorded in the error log when this occurs.

This directive is not supported on Windows.

opcache.error_log string

The error log for OPcache errors. An empty string is treated the same as stderr, and will result in logs being sent to standard error (which will be the Web server error log in most cases).

opcache.log_verbosity_level int

The log verbosity level. By default, only fatal errors (level 0) and errors (level 1) are logged. Other levels available are warnings (level 2), information messages (level 3) and debug messages (level 4).

opcache.record_warnings bool

If enabled, OPcache will record compile-time warnings and replay them on the next include, even if it is served from cache.

opcache.preferred_memory_model string

The preferred memory model for OPcache to use. If left empty, OPcache will choose the most appropriate model, which is the correct behaviour in virtually all cases.

Possible values include mmap, shm, posix and win32.

opcache.protect_memory bool

Protects shared memory from unexpected writes while executing scripts. This is useful for internal debugging only.

opcache.mmap_base string

The base used for shared memory segments on Windows. All PHP processes have to map shared memory into the same address space. Using this directive allows "Unable to reattach to base address" errors to be fixed.

opcache.restrict_api string

Allows calling OPcache API functions only from PHP scripts which path is started from specified string. The default "" means no restriction.

opcache.file_update_protection string

Prevents caching files that are less than this number of seconds old. It protects from caching of incompletely updated files. In case all file updates on your site are atomic, you may increase performance by setting it to "0".

opcache.huge_code_pages bool

Enables or disables copying of PHP code (text segment) into HUGE PAGES. This should improve performance, but requires appropriate OS configuration. Available on Linux as of PHP 7.0.0, and on FreeBSD as of PHP 7.4.0.

opcache.lockfile_path string

Absolute path used to store shared lockfiles (for *nix only)

opcache.opt_debug_level string

Produces opcode dumps for debugging different stages of optimizations. 0x10000 will output opcodes as the compiler produced them before any optimization occurs while 0x20000 will output optimized codes.

opcache.file_cache string

Enables and sets the second level cache directory. It should improve performance when SHM memory is full, at server restart or SHM reset. The default "" disables file based caching.

opcache.file_cache_only bool

Enables or disables opcode caching in shared memory.

Note:

Prior to PHP 8.1.0, disabling this directive with an already populated file cache required to manually clear the file cache.

opcache.file_cache_consistency_checks bool

Enables or disables checksum validation when script loaded from file cache.

opcache.file_cache_fallback bool

Implies opcache.file_cache_only=1 for a certain process that failed to reattach to the shared memory (for Windows only). Explicitly enabled file cache is required.

Caution

Disabling this configuration option may prevent processes to start, and is therefore discouraged.

opcache.validate_permission bool

Validates the cached file permissions against the current user.

opcache.validate_root bool

Prevents name collisions in chroot'ed environments. This should be enabled in all chroot'ed environments to prevent access to files outside the chroot.

opcache.preload string

Specifies a PHP script that is going to be compiled and executed at server start-up, and which may preload other files, either by includeing them or by using the opcache_compile_file() function. All the entities (e.g. functions and classes) defined in these files will be available to requests out of the box, until the server is shut down.

Note:

Preloading is not supported on Windows.

opcache.preload_user string

Preloading code as root is not allowed for security reasons. This directive facilitates to let the preloading to be run as another user.

opcache.cache_id string

On Windows, all processes running the same PHP SAPI under the same user account having the same cache ID share a single OPcache instance. The value of the cache ID can be freely chosen.

Tip

For IIS, different application pools can have their own OPcache instance by using the environment variable APP_POOL_ID as opcache.cache_id.

opcache.jit string|int

For typical usage, this option accepts one of four string values:

  • disable: Completely disabled, cannot be enabled at runtime.
  • off: Disabled, but can be enabled at runtime.
  • tracing/on: Use tracing JIT. Enabled by default and recommended for most users.
  • function: Use function JIT.

For advanced usage, this option accepts a 4-digit integer CRTO, where the digits mean:

C (CPU-specific optimization flags)
  • 0: Disable CPU-specific optimization.
  • 1: Enable use of AVX, if the CPU supports it.
R (register allocation)
  • 0: Don't perform register allocation.
  • 1: Perform block-local register allocation.
  • 2: Perform global register allocation.
T (trigger)
  • 0: Compile all functions on script load.
  • 1: Compile functions on first execution.
  • 2: Profile functions on first request and compile the hottest functions afterwards.
  • 3: Profile on the fly and compile hot functions.
  • 4: Currently unused.
  • 5: Use tracing JIT. Profile on the fly and compile traces for hot code segments.
O (optimization level)
  • 0: No JIT.
  • 1: Minimal JIT (call standard VM handlers).
  • 2: Inline VM handlers.
  • 3: Use type inference.
  • 4: Use call graph.
  • 5: Optimize whole script.
The "tracing" mode corresponds to CRTO = 1254, the "function" mode corresponds to CRTO = 1205.

opcache.jit_buffer_size int

The amount of shared memory to reserve for compiled JIT code. A zero value disables the JIT.

When an int is used, the value is measured in bytes. Shorthand notation, as described in this FAQ, may also be used.
opcache.jit_debug int

A bit mask specifying which JIT debug output to enable. For possible values, please consult zend_jit.h.

opcache.jit_bisect_limit int

Debugging option that disables JIT compilation after compiling a certain number of functions. This may be helpful to bisect the source of a JIT miscompilation. Note: this option only works when JIT trigger is set to 0 (compile on script load) or 1 (compile on first execution), e.g., opcache.jit=1215. See more in opcache.jit option.

opcache.jit_prof_threshold float

When using the "profile on first request" trigger mode, this threshold determines whether a function is considered hot. The number of calls to the function divided by the number of calls to all functions must be above the threshold. For example, a threshold of 0.005 means that functions that made up more than 0.5% of all calls will be JIT compiled.

opcache.jit_max_root_traces int

Maximum number of root traces. The root trace is an execution flow taking one path through the code firstly, which is a unit of JIT compilation. JIT will not compile new code if it reaches this limit.

opcache.jit_max_side_traces int

Maximum number of side traces a root trace may have. The side trace is another execution flow that does not follow the path of compiled root trace. Side traces belonging to the same root trace will not be compiled if it reaches this limit.

opcache.jit_max_exit_counters int

Maximum number of side trace exit counters. This limits the total number of side traces there may be, across all root traces.

opcache.jit_hot_loop int

After how many iterations a loop is considered hot. Valid value range is [0,255]; for any setting out of this range, e.g., -1 or 256, default value will be used instead. Specially, a zero value will disable JIT to trace and compile any loops.

opcache.jit_hot_func int

After how many calls a function is considered hot. Valid value range is [0,255]; for any setting out of this range, e.g., -1 or 256, default value will be used instead. Specially, a zero value will disable JIT to trace and compile any functions.

opcache.jit_hot_return int

After how many returns a return is considered hot. Valid value range is [0,255]; for any setting out of this range, e.g., -1 or 256, default value will be used instead. Specially, a zero value will disable JIT to trace and compile any returns.

opcache.jit_hot_side_exit int

After how many exits a side exit is considered hot. Valid value range is [0,255]; for any setting out of this range, e.g., -1 or 256, default value will be used instead. Specially, a zero value will disable JIT to trace and compile any side exits.

opcache.jit_blacklist_root_trace int

Maximum number of times the compilation of a root trace is attempted before it is blacklisted.

opcache.jit_blacklist_side_trace int

Maximum number of times the compilation of a side trace is attempted before it is blacklisted.

opcache.jit_max_loop_unrolls int

Maximum number of attempts to unroll a loop in a side trace, trying to reach the root trace and close the outer loop.

opcache.jit_max_recursive_calls int

Maximum number of unrolled recursive call loops.

opcache.jit_max_recursive_returns int

Maximum number of unrolled recursive return loops.

opcache.jit_max_polymorphic_calls int

Maximum number of attempts to inline polymorphic (dynamic or method) calls. Calls above this limit are treated as megamorphic and are not inlined.

Here you can write a comment


Please enter at least 10 characters.
Loading... Please wait.
* Pflichtangabe
There are no comments available yet.

PHP cURL Tutorial: Using cURL to Make HTTP Requests

cURL is a powerful PHP extension that allows you to communicate with different servers using various protocols, including HTTP, HTTPS, FTP, and more. ...

TheMax

Autor : TheMax
Category: PHP-Tutorials

Midjourney Tutorial - Instructions for beginners

There is an informative video about Midjourney, the tool for creating digital images using artificial intelligence, entitled "Midjourney tutorial in German - instructions for beginners" ...

Mike94

Autor : Mike94
Category: KI Tutorials

Basics of views in MySQL

Views in a MySQL database offer the option of creating a virtual table based on the result of an SQL query. This virtual table can be queried like a normal table without changing the underlying data. ...

admin

Autor : admin
Category: mySQL-Tutorials

Publish a tutorial

Share your knowledge with other developers worldwide

Share your knowledge with other developers worldwide

You are a professional in your field and want to share your knowledge, then sign up now and share it with our PHP community

learn more

Publish a tutorial