Skip to content

Commit efa1436

Browse files
committed
minor symfony#13204 [2.3] [ClassLoader] removes deprecated classes from documentation. (hhamon)
This PR was merged into the 2.3 branch. Discussion ---------- [2.3] [ClassLoader] removes deprecated classes from documentation. | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | ~ | License | MIT | Doc PR | ~ Commits ------- 57bd898 [ClassLoader] removes deprecated classes from documentation.
2 parents 6de747e + 57bd898 commit efa1436

File tree

4 files changed

+52
-24
lines changed

4 files changed

+52
-24
lines changed

src/Symfony/Component/ClassLoader/ApcClassLoader.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,19 @@
1717
* It expects an object implementing a findFile method to find the file. This
1818
* allows using it as a wrapper around the other loaders of the component (the
1919
* ClassLoader and the UniversalClassLoader for instance) but also around any
20-
* other autoloader following this convention (the Composer one for instance)
20+
* other autoloaders following this convention (the Composer one for instance).
21+
*
22+
* // with a Symfony autoloader
23+
* use Symfony\Component\ClassLoader\ClassLoader;
2124
*
2225
* $loader = new ClassLoader();
26+
* $loader->addPrefix('Symfony\Component', __DIR__.'/component');
27+
* $loader->addPrefix('Symfony', __DIR__.'/framework');
28+
*
29+
* // or with a Composer autoloader
30+
* use Composer\Autoload\ClassLoader;
2331
*
24-
* // register classes with namespaces
32+
* $loader = new ClassLoader();
2533
* $loader->add('Symfony\Component', __DIR__.'/component');
2634
* $loader->add('Symfony', __DIR__.'/framework');
2735
*

src/Symfony/Component/ClassLoader/README.md

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,34 @@ ClassLoader Component
44
ClassLoader loads your project classes automatically if they follow some
55
standard PHP conventions.
66

7-
The Universal ClassLoader is able to autoload classes that implement the PSR-0
7+
The ClassLoader object is able to autoload classes that implement the PSR-0
88
standard or the PEAR naming convention.
99

1010
First, register the autoloader:
1111

1212
```php
13-
require_once __DIR__.'/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
13+
require_once __DIR__.'/src/Symfony/Component/ClassLoader/ClassLoader.php';
1414

15-
use Symfony\Component\ClassLoader\UniversalClassLoader;
15+
use Symfony\Component\ClassLoader\ClassLoader;
1616

17-
$loader = new UniversalClassLoader();
17+
$loader = new ClassLoader();
1818
$loader->register();
1919
```
2020

21-
Then, register some namespaces with the `registerNamespace()` method:
21+
Then, register some namespaces with the `addPrefix()` method:
2222

2323
```php
24-
$loader->registerNamespace('Symfony', __DIR__.'/src');
25-
$loader->registerNamespace('Monolog', __DIR__.'/vendor/monolog/src');
24+
$loader->addPrefix('Symfony', __DIR__.'/src');
25+
$loader->addPrefix('Monolog', __DIR__.'/vendor/monolog/src');
2626
```
2727

28-
The `registerNamespace()` method takes a namespace prefix and a path where to
28+
The `addPrefix()` method takes a namespace prefix and a path where to
2929
look for the classes as arguments.
3030

3131
You can also register a sub-namespaces:
3232

3333
```php
34-
$loader->registerNamespace('Doctrine\\Common', __DIR__.'/vendor/doctrine-common/lib');
34+
$loader->addPrefix('Doctrine\\Common', __DIR__.'/vendor/doctrine-common/lib');
3535
```
3636

3737
The order of registration is significant and the first registered namespace
@@ -40,31 +40,35 @@ takes precedence over later registered one.
4040
You can also register more than one path for a given namespace:
4141

4242
```php
43-
$loader->registerNamespace('Symfony', array(__DIR__.'/src', __DIR__.'/symfony/src'));
43+
$loader->addPrefix('Symfony', array(__DIR__.'/src', __DIR__.'/symfony/src'));
4444
```
4545

46-
Alternatively, you can use the `registerNamespaces()` method to register more
46+
Alternatively, you can use the `addPrefixes()` method to register more
4747
than one namespace at once:
4848

4949
```php
50-
$loader->registerNamespaces(array(
50+
$loader->addPrefixes(array(
5151
'Symfony' => array(__DIR__.'/src', __DIR__.'/symfony/src'),
5252
'Doctrine\\Common' => __DIR__.'/vendor/doctrine-common/lib',
5353
'Doctrine' => __DIR__.'/vendor/doctrine/lib',
5454
'Monolog' => __DIR__.'/vendor/monolog/src',
5555
));
5656
```
5757

58-
For better performance, you can use the APC based version of the universal
59-
class loader:
58+
For better performance, you can use the APC class loader:
6059

6160
```php
62-
require_once __DIR__.'/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
63-
require_once __DIR__.'/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php';
61+
require_once __DIR__.'/src/Symfony/Component/ClassLoader/ClassLoader.php';
62+
require_once __DIR__.'/src/Symfony/Component/ClassLoader/ApcClassLoader.php';
6463

65-
use Symfony\Component\ClassLoader\ApcUniversalClassLoader;
64+
use Symfony\Component\ClassLoader\ClassLoader;
65+
use Symfony\Component\ClassLoader\ApcClassLoader;
6666

67-
$loader = new ApcUniversalClassLoader('apc.prefix.');
67+
$loader = new ClassLoader();
68+
$loader->addPrefix('Symfony', __DIR__.'/src');
69+
70+
$loader = new ApcClassLoader('apc.prefix.', $loader);
71+
$loader->register();
6872
```
6973

7074
Furthermore, the component provides tools to aggregate classes into a single

src/Symfony/Component/ClassLoader/WinCacheClassLoader.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,19 @@
1717
* It expects an object implementing a findFile method to find the file. This
1818
* allow using it as a wrapper around the other loaders of the component (the
1919
* ClassLoader and the UniversalClassLoader for instance) but also around any
20-
* other autoloader following this convention (the Composer one for instance)
20+
* other autoloaders following this convention (the Composer one for instance).
21+
*
22+
* // with a Symfony autoloader
23+
* use Symfony\Component\ClassLoader\ClassLoader;
2124
*
2225
* $loader = new ClassLoader();
26+
* $loader->addPrefix('Symfony\Component', __DIR__.'/component');
27+
* $loader->addPrefix('Symfony', __DIR__.'/framework');
28+
*
29+
* // or with a Composer autoloader
30+
* use Composer\Autoload\ClassLoader;
2331
*
24-
* // register classes with namespaces
32+
* $loader = new ClassLoader();
2533
* $loader->add('Symfony\Component', __DIR__.'/component');
2634
* $loader->add('Symfony', __DIR__.'/framework');
2735
*

src/Symfony/Component/ClassLoader/XcacheClassLoader.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,19 @@
1717
* It expects an object implementing a findFile method to find the file. This
1818
* allows using it as a wrapper around the other loaders of the component (the
1919
* ClassLoader and the UniversalClassLoader for instance) but also around any
20-
* other autoloader following this convention (the Composer one for instance)
20+
* other autoloaders following this convention (the Composer one for instance).
21+
*
22+
* // with a Symfony autoloader
23+
* use Symfony\Component\ClassLoader\ClassLoader;
2124
*
2225
* $loader = new ClassLoader();
26+
* $loader->addPrefix('Symfony\Component', __DIR__.'/component');
27+
* $loader->addPrefix('Symfony', __DIR__.'/framework');
28+
*
29+
* // or with a Composer autoloader
30+
* use Composer\Autoload\ClassLoader;
2331
*
24-
* // register classes with namespaces
32+
* $loader = new ClassLoader();
2533
* $loader->add('Symfony\Component', __DIR__.'/component');
2634
* $loader->add('Symfony', __DIR__.'/framework');
2735
*

0 commit comments

Comments
 (0)