-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Remove outdated performance tips #8556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,8 +96,7 @@ value too using the ``realpath_cache_ttl`` option: | |
Use Composer's Class Map Functionality | ||
-------------------------------------- | ||
|
||
By default, the Symfony Standard Edition uses Composer's autoloader | ||
in the `autoload.php`_ file. This autoloader is easy to use, as it will | ||
Symfony uses Composer's autoloader. This autoloader is easy to use, as it will | ||
automatically find any new classes that you've placed in the registered | ||
directories. | ||
|
||
|
@@ -125,82 +124,6 @@ your deploy process: | |
Prevents Composer from scanning the file system for classes that are not | ||
found in the class map. | ||
|
||
Caching the Autoloader with APC | ||
------------------------------- | ||
|
||
Another solution is to cache the location of each class after it's located | ||
the first time. Symfony comes with a class - :class:`Symfony\\Component\\ClassLoader\\ApcClassLoader` - | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. component deprecated |
||
that does exactly this. To use it, just adapt your front controller file. | ||
If you're using the Standard Distribution, make the following changes:: | ||
|
||
// app.php | ||
// ... | ||
|
||
use Symfony\Component\ClassLoader\ApcClassLoader; | ||
|
||
// do not use $loader as a variable name here as it would | ||
// be overwritten when loading the bootstrap.php.cache file | ||
$classLoader = require __DIR__.'/../app/autoload.php'; | ||
include_once __DIR__.'/../app/bootstrap.php.cache'; | ||
|
||
// Use APC for autoloading to improve performance | ||
// Change 'sf2' by the prefix you want in order | ||
// to prevent key conflict with another application | ||
$loader = new ApcClassLoader('sf2', $classLoader); | ||
$loader->register(true); | ||
|
||
// ... | ||
|
||
For more details, see :doc:`/components/class_loader/cache_class_loader`. | ||
|
||
.. note:: | ||
|
||
When using the APC autoloader, if you add new classes, they will be found | ||
automatically and everything will work the same as before (i.e. no | ||
reason to "clear" the cache). However, if you change the location of a | ||
particular namespace or prefix, you'll need to flush your APC cache. Otherwise, | ||
the autoloader will still be looking at the old location for all classes | ||
inside that namespace. | ||
|
||
.. index:: | ||
single: Performance; Bootstrap files | ||
|
||
Use Bootstrap Files | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not recommended anymore, esp. with php 7 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. technically this is still relevant for php 5 (as you know), but I'm +1 for removing it... because users already have this code - PHP 5 users don't need to take any action. |
||
------------------- | ||
|
||
To ensure optimal flexibility and code reuse, Symfony applications leverage | ||
a variety of classes and 3rd party components. But loading all of these classes | ||
from separate files on each request can result in some overhead. To reduce | ||
this overhead, the Symfony Standard Edition provides a script to generate | ||
a so-called `bootstrap file`_, consisting of multiple classes definitions | ||
in a single file. By including this file (which contains a copy of many of | ||
the core classes), Symfony no longer needs to include any of the source files | ||
containing those classes. This will reduce disc IO quite a bit. | ||
|
||
If you're using the Symfony Standard Edition, then you're probably already | ||
using the bootstrap file. To be sure, open your front controller (usually | ||
``app.php``) and check to make sure that the following line exists:: | ||
|
||
include_once __DIR__.'/../var/bootstrap.php.cache'; | ||
|
||
Note that there are two disadvantages when using a bootstrap file: | ||
|
||
* the file needs to be regenerated whenever any of the original sources change | ||
(i.e. when you update the Symfony source or vendor libraries); | ||
|
||
* when debugging, one will need to place break points inside the bootstrap file. | ||
|
||
If you're using the Symfony Standard Edition, the bootstrap file is automatically | ||
rebuilt after updating the vendor libraries via the ``composer install`` command. | ||
|
||
Bootstrap Files and Byte Code Caches | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Even when using a byte code cache, performance will improve when using a bootstrap | ||
file since there will be fewer files to monitor for changes. Of course, if this | ||
feature is disabled in the byte code cache (e.g. ``apc.stat=0`` in APC), there | ||
is no longer a reason to use a bootstrap file. | ||
|
||
Learn more | ||
---------- | ||
|
||
|
@@ -213,5 +136,3 @@ Learn more | |
.. _`APC`: http://php.net/manual/en/book.apc.php | ||
.. _`APCu Polyfill component`: https://github.com/symfony/polyfill-apcu | ||
.. _`APCu PHP functions`: http://php.net/manual/en/ref.apcu.php | ||
.. _`autoload.php`: https://github.com/symfony/symfony-standard/blob/master/app/autoload.php | ||
.. _`bootstrap file`: https://github.com/sensiolabs/SensioDistributionBundle/blob/master/Composer/ScriptHandler.php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not exist anymore since symfony/symfony-standard#1056