Now you can set OPcache setting accordingly. Now above will givbe you a numeric count of total PHP script files in your codebase. For frameworks like PHP Magento you could probably have this value bumped up as the core files are large in number.įirst know count of PHP scripting files in your codebase : # Make sure you change this path as per your setup You can increase this number as per your requirement. In the loaded and used php.ini, you can change this setting by updating following directive : mory_consumption=128īy default OPcache can cache 2000 files before PHP 7.0.0 for after versions. Ideally 64MB to 128MB size is more than enough for most of the PHP frameworks. When the entire cache is stored into shared memory, the default max size of that memory storage is 64MB before PHP 7.0.0 and 128MB for after versions. OPCache also can be enabled for CLI, PHP running from the command line interface(terminal) : opcache.enable_cli=1 //Enables OPcache In the loaded and used php.ini, you can enable and disable opcache by updating following directive : opcache.enable=1 //Enables OPcache Or if you have 7.x with apache2 installed then it will be inside /etc/php/7.x/apache2/php.ini. Mostly if you have php version 7.x with fpm installed then it will be inside /etc/php/7.x/fpm/php.ini. Once you open this file into browser, you would be able to see which php.ini is used. OR create a temporary script file called 'info.php` and have following content on it : phpinfo() You need to find the php.ini which is currently in use. Cache handling, cache clearing and cache storing and overall invalidation depends on these settings. Important settings of OPcache :Īs OPcache overall sounds really fascinating which internally optimizes the compilation process of PHP scripts, it is equally important to know the important settings. Why do we really need to compile these core PHP script files which we indeed hardly change? Isn't that an overly unneccessary overhead for PHP compilation process to compile these hundreds of PHP script files on each request and thenm intrepret them? Doesn't make much sense right? There you go. Similarly, the dependency package PHP script are compied as per their need for that particular request. Now, independent of which PHP framework you are using, these core PHP script files which constitute framework more or less are compiled for each request to generate their bytecodes for interpretation. We hardly change these files unless we update/install/remove a package dependency. Now on top of that, we install new PHP packages as and when needed using dependency managers like composer. For example for laravel, we have illuminate's laraval packages. These php package files really let us use the framework capabilities. Any PHP framework has some core package files which we never change. Let's really get into a very vital need of this OPcache in the ever growing world of PHP frameworks. The OPcache extension is bundled with PHP 5.5.0 and later versions. As a result improving overall PHP performance. Therefore removing the requirement for PHP to load and parse scripts on each request. When next time PHP needs to compile the same PHP script, the precompile bytecodes from the shared memory are used. OPcache comes into picture during the compilation phase where it stores the precompiled script's bytecodes into a shared memory. These binaries are compiled into intermediate bytecodes. But the interpretation happens from the binaries.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |