Download the PHP package decodelabs/archetype without Composer
On this page you can find all versions of the php package decodelabs/archetype. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download decodelabs/archetype
More information about decodelabs/archetype
Files in decodelabs/archetype
Informations about the package archetype
Archetype
Simple class name resolution for PHP
Archetype provides a generic frontend to resolving implementation classes for a named interface with an extensible plugin architechture.
Installation
Install via Composer:
Usage
Use Archetype when designing plugin oriented libraries that need to load arbitrary extension classes based on a naming convention.
By mapping names to classes in an extensible and customisable resolver structure, Archetype allows fast and reliable means to create loosely coupled plugin ecosystems.
Example:
Resolvers
Archetype uses a hierarchy of Resolvers
to turn a name into a class. By default, the Handler
will fall back on a generic resolver that simply locates the named class within the namespace of the associated interface.
In the above example, the implementations of the My\Library\Thing
can be found at My\Library\Thing\\*
.
Custom resolvers
The Resolver\Archetype
implementation however will also automatically look for custom Resolver
classes in the same location as the target interface, named \<Interface\>Archetype
.
The following example will replace the default functionality and cause Archetype to look in a different location for the Thing
implementations:
Multiple resolvers
Multiple Resolver
instances can be stacked against a single interface, called in series based on the priority they request, the first one to return a non-null class name wins.
Alternative Resolvers
can be loaded with:
Class scanning
Some resolvers (including the default one) can scan and list all classes resolvable under a namespace.
File lookup
Resolvers
that also implement the Finder
interface can define the means to lookup a file path based on the provided name, against the space defined by the target interface.
This can be useful when the space that is defined by the root interface may contain assets aside from PHP code.
It is down to the implementation to decide how to map names to file paths (there are no pre-built default Finder
classes).
Example:
Licensing
Archetype is licensed under the MIT License. See LICENSE for the full license text.
All versions of archetype with dependencies
decodelabs/exceptional Version ^0.5.2
decodelabs/glitch-support Version ^0.5.1
decodelabs/veneer Version ^0.12.2