<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Runtime Configuration</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="opcache.installation.html">Installation</a></div> <div class="next" style="text-align: right; float: right;"><a href="opcache.resources.html">Resource Types</a></div> <div class="up"><a href="opcache.setup.html">Installing/Configuring</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="opcache.configuration" class="sect1"> <h2 class="title">Runtime Configuration</h2> <p class="simpara"> The behaviour of these functions is affected by settings in <var class="filename">php.ini</var>. </p> <p class="para"> <table class="doctable table"> <caption><strong>OPcache configuration options</strong></caption> <thead> <tr> <th>Name</th> <th>Default</th> <th>Changeable</th> <th>Changelog</th> </tr> </thead> <tbody class="tbody"> <tr> <td><a href="opcache.configuration.html#ini.opcache.enable" class="link">opcache.enable</a></td> <td>"1"</td> <td>PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr> <td><a href="opcache.configuration.html#ini.opcache.enable-cli" class="link">opcache.enable_cli</a></td> <td>"0"</td> <td>PHP_INI_SYSTEM</td> <td class="empty"> </td> </tr> <tr> <td><a href="opcache.configuration.html#ini.opcache.memory-consumption" class="link">opcache.memory_consumption</a></td> <td>"64"</td> <td>PHP_INI_SYSTEM</td> <td class="empty"> </td> </tr> <tr> <td><a href="opcache.configuration.html#ini.opcache.interned-strings-buffer" class="link">opcache.interned_strings_buffer</a></td> <td>"4"</td> <td>PHP_INI_SYSTEM</td> <td>Available since PHP 5.3.0.</td> </tr> <tr> <td><a href="opcache.configuration.html#ini.opcache.max-accelerated-files" class="link">opcache.max_accelerated_files</a></td> <td>"2000"</td> <td>PHP_INI_SYSTEM</td> <td class="empty"> </td> </tr> <tr> <td><a href="opcache.configuration.html#ini.opcache.max-wasted-percentage" class="link">opcache.max_wasted_percentage</a></td> <td>"5"</td> <td>PHP_INI_SYSTEM</td> <td class="empty"> </td> </tr> <tr> <td><a href="opcache.configuration.html#ini.opcache.use-cwd" class="link">opcache.use_cwd</a></td> <td>"1"</td> <td>PHP_INI_SYSTEM</td> <td class="empty"> </td> </tr> <tr> <td><a href="opcache.configuration.html#ini.opcache.validate-timestamps" class="link">opcache.validate_timestamps</a></td> <td>"1"</td> <td>PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr> <td><a href="opcache.configuration.html#ini.opcache.revalidate-freq" class="link">opcache.revalidate_freq</a></td> <td>"2"</td> <td>PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr> <td><a href="opcache.configuration.html#ini.opcache.revalidate-path" class="link">opcache.revalidate_path</a></td> <td>"0"</td> <td>PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr> <td><a href="opcache.configuration.html#ini.opcache.save-comments" class="link">opcache.save_comments</a></td> <td>"1"</td> <td>PHP_INI_SYSTEM</td> <td class="empty"> </td> </tr> <tr> <td><a href="opcache.configuration.html#ini.opcache.load-comments" class="link">opcache.load_comments</a></td> <td>"1"</td> <td>PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr> <td><a href="opcache.configuration.html#ini.opcache.fast-shutdown" class="link">opcache.fast_shutdown</a></td> <td>"0"</td> <td>PHP_INI_SYSTEM</td> <td class="empty"> </td> </tr> <tr> <td><a href="opcache.configuration.html#ini.opcache.enable-file-override" class="link">opcache.enable_file_override</a></td> <td>"0"</td> <td>PHP_INI_SYSTEM</td> <td class="empty"> </td> </tr> <tr> <td><a href="opcache.configuration.html#ini.opcache.optimization-level" class="link">opcache.optimization_level</a></td> <td>"0xffffffff"</td> <td>PHP_INI_SYSTEM</td> <td class="empty"> </td> </tr> <tr> <td><a href="opcache.configuration.html#ini.opcache.inherited-hack" class="link">opcache.inherited_hack</a></td> <td>"1"</td> <td>PHP_INI_SYSTEM</td> <td class="empty"> </td> </tr> <tr> <td><a href="opcache.configuration.html#ini.opcache.dups-fix" class="link">opcache.dups_fix</a></td> <td>"0"</td> <td>PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr> <td><a href="opcache.configuration.html#ini.opcache.blacklist-filename" class="link">opcache.blacklist_filename</a></td> <td>""</td> <td>PHP_INI_SYSTEM</td> <td class="empty"> </td> </tr> <tr> <td><a href="opcache.configuration.html#ini.opcache.max-file-size" class="link">opcache.max_file_size</a></td> <td>"0"</td> <td>PHP_INI_SYSTEM</td> <td class="empty"> </td> </tr> <tr> <td><a href="opcache.configuration.html#ini.opcache.consistency-checks" class="link">opcache.consistency_checks</a></td> <td>"0"</td> <td>PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr> <td><a href="opcache.configuration.html#ini.opcache.force-restart-timeout" class="link">opcache.force_restart_timeout</a></td> <td>"180"</td> <td>PHP_INI_SYSTEM</td> <td class="empty"> </td> </tr> <tr> <td><a href="opcache.configuration.html#ini.opcache.error-log" class="link">opcache.error_log</a></td> <td>""</td> <td>PHP_INI_SYSTEM</td> <td class="empty"> </td> </tr> <tr> <td><a href="opcache.configuration.html#ini.opcache.log-verbosity-level" class="link">opcache.log_verbosity_level</a></td> <td>"1"</td> <td>PHP_INI_SYSTEM</td> <td class="empty"> </td> </tr> <tr> <td><a href="opcache.configuration.html#ini.opcache.preferred-memory-model" class="link">opcache.preferred_memory_model</a></td> <td>""</td> <td>PHP_INI_SYSTEM</td> <td class="empty"> </td> </tr> <tr> <td><a href="opcache.configuration.html#ini.opcache.protect-memory" class="link">opcache.protect_memory</a></td> <td>"0"</td> <td>PHP_INI_SYSTEM</td> <td class="empty"> </td> </tr> <tr> <td><a href="opcache.configuration.html#ini.opcache.mmap-base" class="link">opcache.mmap_base</a></td> <td><strong><code>NULL</code></strong></td> <td>PHP_INI_SYSTEM</td> <td class="empty"> </td> </tr> </tbody> </table> For further details and definitions of the PHP_INI_* modes, see the <a href="configuration.changes.modes.html" class="xref">Where a configuration setting may be set</a>. </p> <p class="para">Here's a short explanation of the configuration directives.</p> <p class="para"> <dl> <dt id="ini.opcache.enable"> <span class="term"> <em><code class="parameter">opcache.enable</code></em> <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span> </span> <dd> <p class="para"> Enables the opcode cache. When disabled, code is not optimised and cached. </p> </dd> </dt> <dt id="ini.opcache.enable-cli"> <span class="term"> <em><code class="parameter">opcache.enable_cli</code></em> <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span> </span> <dd> <p class="para"> Enables the opcode cache for the CLI version of PHP. This is mostly useful for testing and debugging. </p> </dd> </dt> <dt id="ini.opcache.memory-consumption"> <span class="term"> <em><code class="parameter">opcache.memory_consumption</code></em> <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span> </span> <dd> <p class="para"> The size of the shared memory storage used by OPcache, in megabytes. </p> </dd> </dt> <dt id="ini.opcache.interned-strings-buffer"> <span class="term"> <em><code class="parameter">opcache.interned_strings_buffer</code></em> <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span> </span> <dd> <p class="para"> The amount of memory used to store interned strings, in megabytes. This configuration directive is ignored in PHP < 5.3.0. </p> </dd> </dt> <dt id="ini.opcache.max-accelerated-files"> <span class="term"> <em><code class="parameter">opcache.max_accelerated_files</code></em> <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span> </span> <dd> <p class="para"> 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 <em>{ 223, 463, 983, 1979, 3907, 7963, 16229, 32531, 65407, 130987 }</em> that is bigger than the configured value. Only numbers between 200 and 100000 are allowed. </p> </dd> </dt> <dt id="ini.opcache.max-wasted-percentage"> <span class="term"> <em><code class="parameter">opcache.max_wasted_percentage</code></em> <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span> </span> <dd> <p class="para"> The maximum percentage of wasted memory that is allowed before a restart is scheduled. </p> </dd> </dt> <dt id="ini.opcache.use-cwd"> <span class="term"> <em><code class="parameter">opcache.use_cwd</code></em> <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span> </span> <dd> <p class="para"> 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. </p> </dd> </dt> <dt id="ini.opcache.validate-timestamps"> <span class="term"> <em><code class="parameter">opcache.validate_timestamps</code></em> <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span> </span> <dd> <p class="para"> If enabled, OPcache will check for updated scripts every <a href="opcache.configuration.html#ini.opcache.revalidate-freq" class="link">opcache.revalidate_freq</a> seconds. When this directive is disabled, you must reset OPcache manually via <span class="function"><a href="function.opcache-reset.html" class="function">opcache_reset()</a></span>, <span class="function"><a href="function.opcache-invalidate.html" class="function">opcache_invalidate()</a></span> or by restarting the Web server for changes to the filesystem to take effect. </p> </dd> </dt> <dt id="ini.opcache.revalidate-freq"> <span class="term"> <em><code class="parameter">opcache.revalidate_freq</code></em> <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span> </span> <dd> <p class="para"> How often to check script timestamps for updates, in seconds. <em>0</em> will result in OPcache checking for updates on every request. </p> <p class="para"> This configuration directive is ignored if <a href="opcache.configuration.html#ini.opcache.validate-timestamps" class="link">opcache.validate_timestamps</a> if disabled. </p> </dd> </dt> <dt id="ini.opcache.revalidate-path"> <span class="term"> <em><code class="parameter">opcache.revalidate_path</code></em> <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span> </span> <dd> <p class="para"> If disabled, existing cached files using the same <a href="ini.core.html#ini.include-path" class="link">include_path</a> will be reused. Thus, if a file with the same name is elsewhere in the include_path, it won't be found. </p> </dd> </dt> <dt id="ini.opcache.save-comments"> <span class="term"> <em><code class="parameter">opcache.save_comments</code></em> <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span> </span> <dd> <p class="para"> 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. </p> </dd> </dt> <dt id="ini.opcache.load-comments"> <span class="term"> <em><code class="parameter">opcache.load_comments</code></em> <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span> </span> <dd> <p class="para"> If disabled, documentation comments won't be loaded from the opcode cache even if they exist. This can be used with <a href="opcache.configuration.html#ini.opcache.save-comments" class="link">opcache.save_comments</a> to only load comments for applications that require them. </p> </dd> </dt> <dt id="ini.opcache.fast-shutdown"> <span class="term"> <em><code class="parameter">opcache.fast_shutdown</code></em> <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span> </span> <dd> <p class="para"> 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. </p> </dd> </dt> <dt id="ini.opcache.enable-file-override"> <span class="term"> <em><code class="parameter">opcache.enable_file_override</code></em> <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span> </span> <dd> <p class="para"> When enabled, the opcode cache will be checked for whether a file has already been cached when <span class="function"><a href="function.file-exists.html" class="function">file_exists()</a></span>, <span class="function"><a href="function.is-file.html" class="function">is_file()</a></span> and <span class="function"><a href="function.is-readable.html" class="function">is_readable()</a></span> are called. This may increase performance in applications that check the existence and readability of PHP scripts, but risks returning stale data if <a href="opcache.configuration.html#ini.opcache.validate-timestamps" class="link">opcache.validate_timestamps</a> is disabled. </p> </dd> </dt> <dt id="ini.opcache.optimization-level"> <span class="term"> <em><code class="parameter">opcache.optimization_level</code></em> <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span> </span> <dd> <p class="para"> A bitmask that controls which optimisation passes are executed. </p> </dd> </dt> <dt id="ini.opcache.inherited-hack"> <span class="term"> <em><code class="parameter">opcache.inherited_hack</code></em> <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span> </span> <dd> <p class="para"> In PHP < 5.3, OPcache stores the places where <a href="internals2.opcodes.declare-class.html" class="link">DECLARE_CLASS</a> opcodes used inheritance; when the file is loaded, OPcache then tries to bind the inherited classes using the current environment. The problem is that while the DECLARE_CLASS opcode may not be needed for the current script, if the script requires that the opcode be defined, it may not run. </p> <p class="para"> This configuration directive is ignored in PHP 5.3 and later. </p> </dd> </dt> <dt id="ini.opcache.dups-fix"> <span class="term"> <em><code class="parameter">opcache.dups_fix</code></em> <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span> </span> <dd> <p class="para"> This hack should only be enabled to work around "Cannot redeclare class" errors. </p> </dd> </dt> <dt id="ini.opcache.blacklist-filename"> <span class="term"> <em><code class="parameter">opcache.blacklist_filename</code></em> <span class="type"><a href="language.types.string.html" class="type string">string</a></span> </span> <dd> <p class="para"> 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. </p> <p class="para"> A simple blacklist file might look as follows: </p> <div class="informalexample"> <div class="example-contents"> <div class="cdata"><pre> ; 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 </pre></div> </div> </div> </dd> </dt> <dt id="ini.opcache.max-file-size"> <span class="term"> <em><code class="parameter">opcache.max_file_size</code></em> <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span> </span> <dd> <p class="para"> The maximum file size that will be cached, in bytes. If this is <em>0</em>, all files will be cached. </p> </dd> </dt> <dt id="ini.opcache.consistency-checks"> <span class="term"> <em><code class="parameter">opcache.consistency_checks</code></em> <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span> </span> <dd> <p class="para"> 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. </p> </dd> </dt> <dt id="ini.opcache.force-restart-timeout"> <span class="term"> <em><code class="parameter">opcache.force_restart_timeout</code></em> <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span> </span> <dd> <p class="para"> 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. </p> <p class="para"> If <a href="opcache.configuration.html#ini.opcache.log-verbosity-level" class="link">opcache.log_verbosity_level</a> is set to 3 or above, an error will be recorded in the error log when this occurs. </p> </dd> </dt> <dt id="ini.opcache.error-log"> <span class="term"> <em><code class="parameter">opcache.error_log</code></em> <span class="type"><a href="language.types.string.html" class="type string">string</a></span> </span> <dd> <p class="para"> The error log for OPcache errors. An empty string is treated the same as <em>stderr</em>, and will result in logs being sent to standard error (which will be the Web server error log in most cases). </p> </dd> </dt> <dt id="ini.opcache.log-verbosity-level"> <span class="term"> <em><code class="parameter">opcache.log_verbosity_level</code></em> <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span> </span> <dd> <p class="para"> 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). </p> </dd> </dt> <dt id="ini.opcache.preferred-memory-model"> <span class="term"> <em><code class="parameter">opcache.preferred_memory_model</code></em> <span class="type"><a href="language.types.string.html" class="type string">string</a></span> </span> <dd> <p class="para"> 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. </p> <p class="para"> Possible values include <em>mmap</em>, <em>shm</em>, <em>posix</em> and <em>win32</em>. </p> </dd> </dt> <dt id="ini.opcache.protect-memory"> <span class="term"> <em><code class="parameter">opcache.protect_memory</code></em> <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span> </span> <dd> <p class="para"> Protects shared memory from unexpected writes while executing scripts. This is useful for internal debugging only. </p> </dd> </dt> <dt id="ini.opcache.mmap-base"> <span class="term"> <em><code class="parameter">opcache.mmap_base</code></em> <span class="type"><a href="language.types.string.html" class="type string">string</a></span> </span> <dd> <p class="para"> 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. </p> </dd> </dt> </dl> </p> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="opcache.installation.html">Installation</a></div> <div class="next" style="text-align: right; float: right;"><a href="opcache.resources.html">Resource Types</a></div> <div class="up"><a href="opcache.setup.html">Installing/Configuring</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>