@@ -12,15 +12,15 @@ application even faster.
12
12
.. index ::
13
13
single: Performance; Byte code cache
14
14
15
- Use a Byte Code Cache (e.g. APC )
16
- --------------------------------
15
+ Use a Byte Code Cache (e.g. OPcache )
16
+ ------------------------------------
17
17
18
18
One of the best (and easiest) things that you should do to improve your performance
19
19
is to use a "byte code cache". The idea of a byte code cache is to remove
20
20
the need to constantly recompile the PHP source code. There are a number of
21
21
`byte code caches `_ available, some of which are open source. As of PHP 5.5,
22
22
PHP 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 `_.
24
24
25
25
Using a byte code cache really has no downside, and Symfony has been architected
26
26
to perform really well in this type of environment.
@@ -43,6 +43,25 @@ your ``php.ini`` configuration.
43
43
.. index ::
44
44
single: Performance; Autoloader
45
45
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
+
46
65
Use Composer's Class Map Functionality
47
66
--------------------------------------
48
67
@@ -52,18 +71,25 @@ automatically find any new classes that you've placed in the registered
52
71
directories.
53
72
54
73
Unfortunately, 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
56
75
finally finds the file it's looking for.
57
76
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:
61
83
62
84
.. code-block :: bash
63
85
64
- $ composer dump-autoload --optimize
86
+ $ composer dump-autoload --optimize --no-dev --classmap-authoritative
65
87
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.
67
93
68
94
Caching the Autoloader with APC
69
95
-------------------------------
0 commit comments