mirror of
https://github.com/danog/class-finder.git
synced 2025-01-23 06:11:26 +01:00
Update docs
This commit is contained in:
parent
4a5e77632d
commit
f7fca13795
49
README.md
49
README.md
@ -26,13 +26,23 @@ No other installation methods are currently supported.
|
||||
Supported Autoloading Methods
|
||||
--------------------------------
|
||||
|
||||
* PSR-4
|
||||
* Classmaps
|
||||
* Files (Experimental, must be explicitly enabled via `ClassFinder::enableExperimentalFilesSupport()`)
|
||||
| Method | Supported | with `ClassFinder::RECURSIVE_MODE` |
|
||||
| ---------- | --------- | ---------------------------------- |
|
||||
| PSR-4 | ✔️ | ✔️ |
|
||||
| PSR-0 | ❌️* | ❌️* |
|
||||
| Classmap | ✔️ | ✔️ |
|
||||
| Files | ✔️^ | ❌️** |
|
||||
|
||||
\^ Experimental.
|
||||
|
||||
Example
|
||||
-------
|
||||
\* Planned.
|
||||
|
||||
\** Not planned. Open an issue if you need this feature.
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
**Standard Mode**
|
||||
|
||||
```
|
||||
<?php
|
||||
@ -51,6 +61,31 @@ $classes = ClassFinder::getClassesInNamespace('TestApp1\Foo');
|
||||
var_dump($classes);
|
||||
```
|
||||
|
||||
**Recursive Mode** *(in v0.3-beta)*
|
||||
|
||||
```
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
$classes = ClassFinder::getClassesInNamespace('TestApp1\Foo', ClassFinder::RECURSIVE_MODE);
|
||||
|
||||
/**
|
||||
* array(
|
||||
* 'TestApp1\Foo\Bar',
|
||||
* 'TestApp1\Foo\Baz',
|
||||
* 'TestApp1\Foo\Foo',
|
||||
* 'TestApp1\Foo\Box\Bar',
|
||||
* 'TestApp1\Foo\Box\Baz',
|
||||
* 'TestApp1\Foo\Box\Foo',
|
||||
* 'TestApp1\Foo\Box\Lon\Bar',
|
||||
* 'TestApp1\Foo\Box\Lon\Baz',
|
||||
* 'TestApp1\Foo\Box\Lon\Foo',
|
||||
* )
|
||||
*/
|
||||
var_dump($classes);
|
||||
```
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
@ -87,8 +122,8 @@ may be introduced in minor 0.X.Y versions, where X changes.
|
||||
|
||||
Various ideas:
|
||||
|
||||
* `ClassFinder::getClassesInNamespace('TestApp1\Foo', ClassFinder::RECURSIVE_MODE)`.
|
||||
Providing classes multiple namespaces deep.
|
||||
* ~~`ClassFinder::getClassesInNamespace('TestApp1\Foo', ClassFinder::RECURSIVE_MODE)`.
|
||||
Providing classes multiple namespaces deep.~~ (included v0.3-beta)
|
||||
|
||||
* `ClassFinder::getClassesImplementingInterface('TestApp1\Foo', 'TestApp1\FooInterface', ClassFinder::RECURSIVE_MODE)`.
|
||||
Filtering classes to only classes that implement a namespace.
|
||||
|
@ -1,3 +1,57 @@
|
||||
Version 0.3.0 Beta
|
||||
------------------
|
||||
|
||||
* [#3](https://gitlab.com/hpierce1102/ClassFinder/issues/3) Added support for "recursive mode". Invoking `ClassFinder::getClassesInNamespace()`
|
||||
in this mode will result in classes in subnamespaces being turned up.
|
||||
|
||||
```
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
$classes = ClassFinder::getClassesInNamespace('TestApp1\Foo', ClassFinder::RECURSIVE_MODE);
|
||||
|
||||
/**
|
||||
* array(
|
||||
* 'TestApp1\Foo\Bar',
|
||||
* 'TestApp1\Foo\Baz',
|
||||
* 'TestApp1\Foo\Foo',
|
||||
* 'TestApp1\Foo\Box\Bar',
|
||||
* 'TestApp1\Foo\Box\Baz',
|
||||
* 'TestApp1\Foo\Box\Foo',
|
||||
* 'TestApp1\Foo\Box\Lon\Bar',
|
||||
* 'TestApp1\Foo\Box\Lon\Baz',
|
||||
* 'TestApp1\Foo\Box\Lon\Foo',
|
||||
* )
|
||||
*/
|
||||
var_dump($classes);
|
||||
```
|
||||
|
||||
* Added **experimental** support for classes that have been included via `files` entries in `composer.json`. Including this feature
|
||||
is a significant drain on performance, so it must be explicitly enabled.
|
||||
|
||||
```
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
ClassFinder::enableExperimentalFilesSupport();
|
||||
|
||||
$classes = ClassFinder::getClassesInNamespace('TestApp1\Foo');
|
||||
```
|
||||
|
||||
* PSR4 features can now be disabled. Disabling autoloading features that you don't need will probably improve performance.
|
||||
|
||||
```
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
ClassFinder::disablePSR4Support();
|
||||
|
||||
$classes = ClassFinder::getClassesInNamespace('TestApp1\Foo');
|
||||
```
|
||||
|
||||
Version 0.2.0
|
||||
-------------
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user