There is no license information available for the latest version (v0.2.1) of this package.
Phemto PHP Dependency Injection Framework
v0.2.1 2013-04-08 07:38 UTC
Phemto ====== What is phemto? Phemto is a dependency injector for PHP 5. It's the smallest dependency injector I could come up with that is still useful in a PHP environment. Because of it's simplicity it makes an ideal tool to learn about dependency injection or for managing medium applications or small frameworks. If your needs are more sophisticated, then you might want to look at the Pico for PHP. The core of a dependency injector is it's internal registry. This can hold single instances or factories and allow global access. However it has several capabilities that place it above a simple Registry pattern. The first is that construction can be initiated with only an interface name in the code that uses the instance. This decouples this client code from dependent object construction. This is a powerful feature for frameworks that may utilise plug-ins from many different authors. The framework can specify interfaces, and utillise code that uses those interfaces, without ever coming into contact with the implementation code. The application author determines the wiring when the injector is set up. This also makes testing easier, because mock implementations can be passed to the application during testing. The second capability is to automatically handle constructor arguments by the same process. This means that implementations can also publicise their dependencies which can in turn be managed by the injector. As the publishing mechanism is as simple type hints in the constructor, it means that the component implementation is not just independent of the framework and it's own constructor dependencies, it's also independent of the injector as well. The third capability is to detach the lifecycle of the object from the class. The injector can register a class as a normal object, a Singleton, a session object or any other lifecycle choice. This decision is kept out of the original class and also out of the client code of the instance. This means that the class itself is not cluttered by this code and, being a normal object, is easy to test. Your own lifecycles can be easily created. A dependency injector achieves a remarkable degree of decoupling. To allow some of this "automagic" behaviour to be nailed down a little, and also to make use of code not especially written for the injector, additional configuration can be set up in a wiring file. With a wiring file, variable names can be mapped to interfaces, decorators and proxies can be applied, and context specific instantiations can be introduced. Phemto is public domain code. The only requirement is to acknowledge the authors in articles where phemto is used as an example. No warranty is implied by this. You use this code entirely at your own risk. yours, Marcus