Download the PHP package kafkiansky/discovery without Composer
On this page you can find all versions of the php package kafkiansky/discovery. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kafkiansky/discovery
More information about kafkiansky/discovery
Files in kafkiansky/discovery
Package discovery
Short Description Discover interfaces, traits and classes from application autoload classmap.
License MIT
Informations about the package discovery
PHP Discovery
Contents
- Installation
- Usage
- ClassImplements
- ClassExtends
- ClassUses
- ClassHasAttributes
- All
- Any
- None
- Loader constraints
- Composer loader
- Array loader
- Performance optimization
- Testing
- License
Installation
Usage
It is often necessary to find all classes that implement specific interface(s), inherit a specific class or use specific traits.
This information could be used, in example, to implement autowiring in IOC containers. To avoid parsing the entire project, you could use classes information from the autoload_classmap.php
file that the composer
uses for optimization.
Class Implements
Discover all classes that implement specific interface(s):
Discover all classes that implement all of specific interfaces:
Discover all classes that implement one of specific interfaces:
Class Extends
Discover all classes that extend specific class:
Class Uses
Discover all classes that use specific trait. This rule recursively searches for the desired trait among the parent traits and among the traits of traits:
Class Has Attributes
Discover all classes that use specific attributes.
All
Discover all classes that satisfy list of rules:
Any
Discover all classes that satisfy at least one rule from list:
None
Discover all classes that do not satisfy any rule:
Loader constraints
If you want to specify which classes can be loaded, you can use the LoaderConstraint
interface implementation.
Out of the box comes the Kafkiansky\Discovery\CodeLocation\Composer\LoadOnlyApplicationCode
class that load only classes that matches namespaces from autoload.psr4
section of your composer.json
file.
Composer loader
By default, the ComposerClassmapClassLoader
search the autoload_classmap.php
in vendor/composer/autoload_classmap.php
path and require it.
If you want pass your own classmap loader, overload the default loader using withClassMapLoader
method:
Array loader
For testing purposes you may use the Kafkiansky\Discovery\CodeLocation\ArrayClassLoader
:
Performance optimization
In production, you will want to cache classes that match the rules to avoid unnecessary checks. Then you must use DiscoveryWithCache
:
Or if you want to cache conditionally, use cacheIf
callable to specify when to cache and when not:
Testing
License
The MIT License (MIT). See License File for more information.