OpCache with Symfony

ε祈祈猫儿з 提交于 2021-02-08 17:14:58

问题


I know you can use with Symfony APC or XCache Class Loader. Unfortunately, in the shared server where I put my Symfony code, there is only OpCache with is activated.

Can I use Symfony with OpCache ? If yes, how and what is the code to put in my app.php please ? If not, why please ?


回答1:


You don't have to do anything in Symfony to enable opcache. You only need to make sure it's enabled in your PHP configuration (opcache_enable option).

Forget APC/XCache class loaders.

APC/XCache class loaders cache paths to classes in memory. It might not necessarily be good for your application, as it would make additional calls to apc/xcache which might be actually slower in some cases.

Optimise your composer class map.

Make sure you dump an optimised composer class map in your production environment:

composer dump-autoload --optimize

This will dump the class map to a single file. OPCache will cache this file, so in most cases it will actually be more performant then using the ApcClassLoader as there's only gonna be one call to the cache.



来源:https://stackoverflow.com/questions/34676278/opcache-with-symfony

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!