Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpCache with Symfony

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 ?

like image 386
virtualmail Avatar asked Mar 14 '23 16:03

virtualmail


1 Answers

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.

like image 118
Jakub Zalas Avatar answered Apr 07 '23 23:04

Jakub Zalas