Zend Framework: Zend_Context Component Proposal
| Proposed Component Name | Zend_Context |
|---|---|
| Developer Notes | http://framework.zend.com/wiki/display/ZFDEV/Zend_Context |
| Proposers | Peter Kovacs |
| Revision | 0.1 - 29 January 2008: Started proposal process 0.2 - 24 Febuary 2008: Proposal ready for review 0.3 - 11 June 2008: Added type casting (wiki revision: 25) |
Table of Contents
1. Overview
Zend_Context implements Dependency Injection.
2. References
- Martin Fowler: Inversion of Control Containers and the Dependency Injection pattern
- MSDN Magazine: Desing Patterns: Dependency Injection
- Spring Framework
- Spring.NET
3. Component Requirements, Constraints, and Acceptance Criteria
- It will read XML or php context files.
- It will not read ini files.
- It will provide a static class for getting objects.
- It will provide methods for creating components from code.
- It will provide interface for reading variables from config files
4. Dependencies on Other Framework Components
- Zend_Exception
- Zend_Loader
5. Theory of Operation
Configure the objects and their relations/dependencies of an application's context in a simple way (php or xml files) and load them easily.
For dynamic component creation and loading there will be a small interface.
There is a more complex approach in:
http://framework.zend.com/wiki/display/ZFPROP/Zend_Di+-+Dependency+Injection+Container
6. Milestones / Tasks
- Milestone 1: [DONE]Design
- Milestone 2: [DONE]Use cases
- Milestone 3: [DONE]Unit tests
- Milestone 4: [DONE]Api doc
- Milestone 5: [DONE]Proposal
- Milestone 6: Work on design, use cases and unit tests from comments
- Milestone 7: Documentation
- Future: New ideas (import, inheritance, scope, validation)
7. Class Index
- Zend_Context (static class)
- Zend_Context_Exception
- Zend_Context_Component
- Zend_Context_Component_Interface
- Zend_Context_Loader (factory class)
- Zend_Context_Loader_Array
- Zend_Context_Loader_Exception
- Zend_Context_Loader_Xml
- Zend_Context_Property
8. Use Cases
| UC-01: XML context file for use cases (test.xml) |
|---|
| UC-02: php context file for use cases (test.php) |
|---|
| UC-03: Loading an xml file and getting an object |
|---|
| UC-04: Loading a php file and getting an object by class |
|---|
| UC-05: Loading context from an array or a Zend_Config object |
|---|
| UC-06: Using properties |
|---|
| UC-07: Using components |
|---|
9. Class Skeletons
Oops, I didn't see that. Thanks for telling.
There are lots of DI implementations. Zend_Di is like PicoContainer's and Zend_Context is like Spring Framework's. I will complete the proposal and than watch, how Zend_Di's proposal will go (and use Zend_Context on my projects, as I do now)
I updated Use Case #5 with a Zend_Config example. I didn't rely on just Zend_Config, because it can not understand attributes of xml nodes. I tend to like xmls for config/context definitions (maybe this comes from using Spring and Eclipse
)
Is this proposal ready for review? If so, please move it to the correct section and announce the move on the mailing list.
Also, there is a proposal that add attribute support to Zend_Config_Xml that is currently under consideration.
Thanks.
,Wil
ZF Home Page
Code Browser
Wiki Dashboard
You might want to review current proposals:
http://framework.zend.com/wiki/display/ZFPROP/Zend_Di+-+Dependency+Injection+Container
At a minimum I would strongly prefer DI to rely on using Zend_Config as input.