我需要在速度方面优化我的 symfony。托管服务器正在运行 php 7.xx 并启用了 opcache。apc_u
扩展被禁用,但如果真的需要,我可以要求启用它。
我现在正在做的是打电话:
composer dump-autoload --optimize
每当我部署我的应用程序时。这样,应用程序应该已经拥有所有需要的映射,而无需遍历文件夹(对吗?)。我想知道如果已经很好地更新,是否ApcClassLoader
可以提高我的表现。autoload_classmap.php
这是我的app.php
第一行:
use Symfony\Component\HttpFoundation\Request;
/**
* @var Composer\Autoload\ClassLoader
*/
$loader = require __DIR__.'/../app/autoload.php';
include_once __DIR__.'/../app/bootstrap.php.cache';
// Enable APC for autoloading to improve performance.
// You should change the ApcClassLoader first argument to a unique prefix
// in order to prevent cache key conflicts with other applications
// also using APC.
/*
$apcLoader = new Symfony\Component\ClassLoader\ApcClassLoader(sha1(__FILE__), $loader);
$loader->unregister();
$apcLoader->register(true);
*/
$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
长问题短:如果已经得到很好的更新,可以ApcClassLoader
提高我的表现吗?autoload_classmap.php