@@ -96,8 +96,7 @@ value too using the ``realpath_cache_ttl`` option:
96
96
Use Composer's Class Map Functionality
97
97
--------------------------------------
98
98
99
- By default, the Symfony Standard Edition uses Composer's autoloader
100
- in the `autoload.php `_ file. This autoloader is easy to use, as it will
99
+ Symfony uses Composer's autoloader. This autoloader is easy to use, as it will
101
100
automatically find any new classes that you've placed in the registered
102
101
directories.
103
102
@@ -125,82 +124,6 @@ your deploy process:
125
124
Prevents Composer from scanning the file system for classes that are not
126
125
found in the class map.
127
126
128
- Caching the Autoloader with APC
129
- -------------------------------
130
-
131
- Another solution is to cache the location of each class after it's located
132
- the first time. Symfony comes with a class - :class: `Symfony\\ Component\\ ClassLoader\\ ApcClassLoader ` -
133
- that does exactly this. To use it, just adapt your front controller file.
134
- If you're using the Standard Distribution, make the following changes::
135
-
136
- // app.php
137
- // ...
138
-
139
- use Symfony\Component\ClassLoader\ApcClassLoader;
140
-
141
- // do not use $loader as a variable name here as it would
142
- // be overwritten when loading the bootstrap.php.cache file
143
- $classLoader = require __DIR__.'/../app/autoload.php';
144
- include_once __DIR__.'/../app/bootstrap.php.cache';
145
-
146
- // Use APC for autoloading to improve performance
147
- // Change 'sf2' by the prefix you want in order
148
- // to prevent key conflict with another application
149
- $loader = new ApcClassLoader('sf2', $classLoader);
150
- $loader->register(true);
151
-
152
- // ...
153
-
154
- For more details, see :doc: `/components/class_loader/cache_class_loader `.
155
-
156
- .. note ::
157
-
158
- When using the APC autoloader, if you add new classes, they will be found
159
- automatically and everything will work the same as before (i.e. no
160
- reason to "clear" the cache). However, if you change the location of a
161
- particular namespace or prefix, you'll need to flush your APC cache. Otherwise,
162
- the autoloader will still be looking at the old location for all classes
163
- inside that namespace.
164
-
165
- .. index ::
166
- single: Performance; Bootstrap files
167
-
168
- Use Bootstrap Files
169
- -------------------
170
-
171
- To ensure optimal flexibility and code reuse, Symfony applications leverage
172
- a variety of classes and 3rd party components. But loading all of these classes
173
- from separate files on each request can result in some overhead. To reduce
174
- this overhead, the Symfony Standard Edition provides a script to generate
175
- a so-called `bootstrap file `_, consisting of multiple classes definitions
176
- in a single file. By including this file (which contains a copy of many of
177
- the core classes), Symfony no longer needs to include any of the source files
178
- containing those classes. This will reduce disc IO quite a bit.
179
-
180
- If you're using the Symfony Standard Edition, then you're probably already
181
- using the bootstrap file. To be sure, open your front controller (usually
182
- ``app.php ``) and check to make sure that the following line exists::
183
-
184
- include_once __DIR__.'/../var/bootstrap.php.cache';
185
-
186
- Note that there are two disadvantages when using a bootstrap file:
187
-
188
- * the file needs to be regenerated whenever any of the original sources change
189
- (i.e. when you update the Symfony source or vendor libraries);
190
-
191
- * when debugging, one will need to place break points inside the bootstrap file.
192
-
193
- If you're using the Symfony Standard Edition, the bootstrap file is automatically
194
- rebuilt after updating the vendor libraries via the ``composer install `` command.
195
-
196
- Bootstrap Files and Byte Code Caches
197
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
198
-
199
- Even when using a byte code cache, performance will improve when using a bootstrap
200
- file since there will be fewer files to monitor for changes. Of course, if this
201
- feature is disabled in the byte code cache (e.g. ``apc.stat=0 `` in APC), there
202
- is no longer a reason to use a bootstrap file.
203
-
204
127
Learn more
205
128
----------
206
129
@@ -213,5 +136,3 @@ Learn more
213
136
.. _`APC` : http://php.net/manual/en/book.apc.php
214
137
.. _`APCu Polyfill component` : https://github.com/symfony/polyfill-apcu
215
138
.. _`APCu PHP functions` : http://php.net/manual/en/ref.apcu.php
216
- .. _`autoload.php` : https://github.com/symfony/symfony-standard/blob/master/app/autoload.php
217
- .. _`bootstrap file` : https://github.com/sensiolabs/SensioDistributionBundle/blob/master/Composer/ScriptHandler.php
0 commit comments