Skip to content

Commit 2e6cfca

Browse files
committed
[ClassLoader] deprecate caching class loaders
1 parent 5b619c9 commit 2e6cfca

File tree

2 files changed

+13
-56
lines changed

2 files changed

+13
-56
lines changed

components/class_loader.rst

+9-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,15 @@ Learn More
5252
:maxdepth: 1
5353

5454
class_loader/class_loader
55-
class_loader/*
55+
class_loader/class_map_generator.rst
56+
class_loader/debug_class_loader.rst
57+
class_loader/map_class_loader.rst
58+
class_loader/psr4_class_loader.rst
59+
60+
.. toctree::
61+
:hidden:
62+
63+
class_loader/cache_class_loader
5664

5765
.. _PSR-0: http://www.php-fig.org/psr/psr-0/
5866
.. _PSR-4: http://www.php-fig.org/psr/psr-4/

components/class_loader/cache_class_loader.rst

+4-55
Original file line numberDiff line numberDiff line change
@@ -8,58 +8,7 @@
88
Cache a Class Loader
99
====================
1010

11-
Finding the file for a particular class can be an expensive task. Luckily,
12-
the ClassLoader component comes with two classes to cache the mapping
13-
from a class to its containing file. Both the :class:`Symfony\\Component\\ClassLoader\\ApcClassLoader`
14-
and the :class:`Symfony\\Component\\ClassLoader\\XcacheClassLoader` wrap
15-
around an object which implements a ``findFile()`` method to find the file
16-
for a class.
17-
18-
.. note::
19-
20-
Both the ``ApcClassLoader`` and the ``XcacheClassLoader`` can be used
21-
to cache Composer's `autoloader`_.
22-
23-
ApcClassLoader
24-
--------------
25-
26-
``ApcClassLoader`` wraps an existing class loader and caches calls to its
27-
``findFile()`` method using `APC`_::
28-
29-
require_once '/path/to/src/Symfony/Component/ClassLoader/ApcClassLoader.php';
30-
31-
// instance of a class that implements a findFile() method, like the ClassLoader
32-
$loader = ...;
33-
34-
// sha1(__FILE__) generates an APC namespace prefix
35-
$cachedLoader = new ApcClassLoader(sha1(__FILE__), $loader);
36-
37-
// register the cached class loader
38-
$cachedLoader->register();
39-
40-
// deactivate the original, non-cached loader if it was registered previously
41-
$loader->unregister();
42-
43-
XcacheClassLoader
44-
-----------------
45-
46-
``XcacheClassLoader`` uses `XCache`_ to cache a class loader. Registering
47-
it is straightforward::
48-
49-
require_once '/path/to/src/Symfony/Component/ClassLoader/XcacheClassLoader.php';
50-
51-
// instance of a class that implements a findFile() method, like the ClassLoader
52-
$loader = ...;
53-
54-
// sha1(__FILE__) generates an XCache namespace prefix
55-
$cachedLoader = new XcacheClassLoader(sha1(__FILE__), $loader);
56-
57-
// register the cached class loader
58-
$cachedLoader->register();
59-
60-
// deactivate the original, non-cached loader if it was registered previously
61-
$loader->unregister();
62-
63-
.. _APC: http://php.net/manual/en/book.apc.php
64-
.. _autoloader: https://getcomposer.org/doc/01-basic-usage.md#autoloading
65-
.. _XCache: http://xcache.lighttpd.net
11+
The ``ApcClassLoader``, the ``WinCacheClassLoader`` and the ``XcacheClassLoader``
12+
are deprecated since Symfony 3.3. Use the ``--optimize`` and ``--apcu-autoloader``
13+
options instead when dumping the autoloader using the ``composer dump-autoload``
14+
command.

0 commit comments

Comments
 (0)