@@ -12,15 +12,15 @@ application even faster.
1212.. index ::
1313 single: Performance; Byte code cache
1414
15- Use a Byte Code Cache (e.g. APC )
16- --------------------------------
15+ Use a Byte Code Cache (e.g. OPcache )
16+ ------------------------------------
1717
1818One of the best (and easiest) things that you should do to improve your performance
1919is to use a "byte code cache". The idea of a byte code cache is to remove
2020the need to constantly recompile the PHP source code. There are a number of
2121`byte code caches `_ available, some of which are open source. As of PHP 5.5,
2222PHP comes with `OPcache `_ built-in. For older versions, the most widely used
23- byte code cache is probably `APC `_
23+ byte code cache is `APC `_.
2424
2525Using a byte code cache really has no downside, and Symfony has been architected
2626to perform really well in this type of environment.
@@ -43,6 +43,25 @@ your ``php.ini`` configuration.
4343.. index ::
4444 single: Performance; Autoloader
4545
46+ Configure the PHP realpath cache
47+ --------------------------------
48+
49+ PHP uses an internal cache to store the result of mapping file paths to their
50+ real and absolute file system paths. This increases the performance for
51+ applications like Symfony that open many PHP files, specially on Windows
52+ systems.
53+
54+ By default PHP sets a default ``realpath_cache_size `` of ``16K `` which is too
55+ low for Symfony. Consider updating this value at least to ``4096K ``. In
56+ addition, cached paths are only stored for ``120 `` seconds. Consider updating
57+ this value too using the ``realpath_cache_ttl `` option:
58+
59+ .. code-block :: ini
60+
61+ ; php.ini
62+ realpath_cache_size =4096K
63+ realpath_cache_ttl =600
64+
4665 Use Composer's Class Map Functionality
4766--------------------------------------
4867
@@ -52,18 +71,25 @@ automatically find any new classes that you've placed in the registered
5271directories.
5372
5473Unfortunately, this comes at a cost, as the loader iterates over all configured
55- namespaces to find a particular file, making ``file_exists `` calls until it
74+ namespaces to find a particular file, making ``file_exists() `` calls until it
5675finally finds the file it's looking for.
5776
58- The simplest solution is to tell Composer to build a "class map" (i.e. a
59- big array of the locations of all the classes). This can be done from the
60- command line, and might become part of your deploy process:
77+ The simplest solution is to tell Composer to build an optimized "class map",
78+ which is a big array of the locations of all the classes and it's stored
79+ in ``vendor/composer/autoload_classmap.php ``.
80+
81+ The class map can be generated from the command line, and might become part of
82+ your deploy process:
6183
6284.. code-block :: bash
6385
64- $ composer dump-autoload --optimize
86+ $ composer dump-autoload --optimize --no-dev --classmap-authoritative
6587
66- Internally, this builds the big class map array in ``vendor/composer/autoload_classmap.php ``.
88+ The ``--optimize `` option dumps every PSR-0 and PSR-4 compatible class used in
89+ your application. The ``--no-dev `` option excludes the classes that are only
90+ needed in the development environment (e.g. tests). The ``--classmap-authoritative ``
91+ option prevents Composer from scanning the file system for classes that are not
92+ found in the class map.
6793
6894Caching the Autoloader with APC
6995-------------------------------
0 commit comments