2. Who Am I?
⢠Ralph Schindler
⢠Software Engineer on the Zend Framework Team at Zend
⢠Email: ralph.schindler@zend.com
⢠Website: http://ralphschindler.com/
⢠Project: http://framework.zend.com/
⢠@ralphschindler (http://twitter.com/ralphschindler)
⢠Slides at: (provide link)
⢠Code download link: (provide link)
2
3. Whatâs Zend_Tool All About, Again?
A quick review of where Zend_Tool came from, and where its
going.
3
4. Whatâs Zend_Tool All About, Again?
⢠Rapid application development of ZF projects
⢠Tooling framework
ď´Framework for building repeatable tooling tasks
ď´Lots of Built in Features
ď´Easily extensible (what this talk is about!)
⢠B/c build systems only get us so far
⢠Tools need to fit in human workflows:
ď´Tool creates project
ď´Human edits project
ď´Tool edits project
ď´Human edits project
ď´... so on and so on ...
4
5. Whatâs Zend_Tool All About, Again?
⢠Zend_Tool in ZF 1.8
⢠Zend_Application in 1.8
⢠Built in project providers:
ď´create projects
ď´create controllers
ď´create actions
ď´create views
ď´create modules
⢠Zend_Reflection & Zend_CodeGenerator in 1.8
5
6. Whatâs Zend_Tool All About, Again?
⢠New features in 1.10
ď´New base loader (no more include_path scanning)
ď´Providers
⢠DbAdapter configuration
⢠DbTable creation based on database tables
⢠Layout enabling and creation
ď´(Web client interface)
6
8. System Overview
⢠Two main âcomponentsâ
ď´Zend_Tool_Framework
⢠The component responsible for dispatching tooling requests
ď´Zend_Tool_Project
⢠The component responsible for exposing the âproject specificâ tooling
capabilities
⢠Auxiliary Components
ď´Zend_Reflection
ď´Zend_CodeGenerator
8
9. System Overview
⢠Zend_Tool_Framework
ď´Dispatch style framework, designed to abstract enough system
internals to make extensibility easy
⢠âFlexibility of the tooling dispatch over speed of tooling dispatchâ
ď´Broken down into logical sub-parts:
⢠Client
⢠Client storage & configuration
⢠Loader
⢠Provider & Provider Repository
⢠Manifest, Manifest Repository & Metadata
⢠System (Built-in) Providers
9
10. System Overview / Zend_Tool_Framework
⢠Zend_Tool_Framework_Client
ď´Responsibilities:
⢠Request object
⢠Response object
⢠Interactivity support
⢠Setting up the system registry containing all required objects
⢠The actual dispatch()-ing
ď´First implementation Zend_Tool_Framework_Client_Console
10
11. System Overview / Zend_Tool_Framework
⢠Zend_Tool_Framework_Client_Storage &
Zend_Tool_Framework_Client_Config
ď´Responsibilities:
⢠Allowing clients to specify configuration values for the system and
providers to use
⢠Allowing clients to store artifacts on the filesystem that the system and
providers can consume
â Custom profile files
â Provider specific file formats and metadata
11
12. System Overview / Zend_Tool_Framework
⢠Zend_Tool_Framework_Loader
ď´Responsibilities:
⢠Load files provided
⢠Search for classes defined that implement:
â Zend_Tool_Framework_Manifest_Interface
â Zend_Tool_Framework_Provider_Interface
ď´Original loader Zend_Tool_Framework_Loader_IncludePathLoader
ď´New loader Zend_Tool_Framework_Loader_BasicLoader
⢠Loads explicitly what it was asked to load
12
13. System Overview / Zend_Tool_Framework
⢠Zend_Tool_Framework_Provider & Provider Registry
ď´Responsibilities:
⢠An interface for defining via a class, dispatch-able actions and
âspecialtiesâ
â (Similar to how Action Controllers define actions)
⢠Registry to maintain instances of all providers available
⢠Parsing of provider classes for dispatch-able âsignaturesâ
13
14. System Overview / Zend_Tool_Framework
⢠Zend_Tool_Framework_Manifest & Manifest Repository
ď´Responsibilities:
⢠Manifest can supply a collection of providers, actions and/or metadata
⢠Registry provides a way to search for metadata in the manifest
⢠Zend_Tool_Framework_Metadata
ď´Responsibilities:
⢠Primary use case is to attach âdata about dataâ to instance of a specific
client, a specific provider, or action
â ex: alternate names for each provider based on the command line naming
scheme, OR short names (p for profile)
14
15. System Overview
⢠Zend_Tool_Project
ď´Problem: How to successfully model all the notions of a âprojectâ?
ď´What is a âprojectâ?
⢠It is a tree of resources (some filesystem / some not)
⢠For each resource we need to capturing itâs ânatureâ or âcontextâ
ď´2 main elements
⢠Zend_Tool_Project_Profile which is a tree of
Zend_Tool_Project_Profile_Resources
⢠Zend_Tool_Project_Context
15
16. System Overview / Zend_Tool_Project
⢠Zend_Tool_Project_Profile
ď´Responsibilities:
⢠loading, parsing, serializing and storing a profile file
⢠Top most node in a âresource treeâ
⢠Zend_Tool_Project_Profile_Resource
ď´Responsibilities:
⢠The class most responsible for the âwhereâ question of project modeling
⢠The class most responsible for implementing a node in a âresource treeâ
⢠Extends Resource_Container which is a RecursiveIterator (tree
fundamentals)
⢠Can create new Resources at specific locations
⢠Can find resources by name and attribute sets
⢠Each contains a Zend_Tool_Project_Context object
16
17. System Overview / Zend_Tool_Project
⢠Zend_Tool_Project_Context
ď´Responsibilities
⢠The class most responsible for the âwhatâ part of project modeling
⢠Is assigned to a Zend_Tool_Project_Profile_Resource object
â (This is known as âcompositionâ)
⢠Example contexts:
â Controller file
â View script directory
â View script file
â Model file
â Action method
â ...
17
18. Building & extending for Zend_Tool
With so many extension points, where does one start?
18
19. Building & Extending For Zend_Tool
⢠Path of least resistance when learning to extend:
ď´Implement a provider, and be able to call it
ď´Implement a manifest for the provider, and be able to call it
ď´Implement some metadata about provider, and be able to find it
ď´Add complex functionality to provider:
⢠Selective interactivity (prompting the user)
⢠Configuration
⢠Use files from user storage area
ď´Implement a new client interface
19
28. Building & Extending For Zend_Tool
⢠Add interactivity to provider
⢠(screenshot)
28
29. Building & Extending For Zend_Tool
⢠Use the config file to retrieve a value
⢠(screenshot)
29
30. Building & Extending For Zend_Tool
⢠Use the storage area to return a file
⢠(screenshot)
30
31. Building & Extending For Zend_Tool
⢠Zend_Tool_Project extensions typical tasks
ď´Load existing profile
ď´Search for resources
ď´Create resources & contexts
⢠Persist attributes
ď´Execute method on resource/contexts, such as create
ď´Store profile after changes
31
32. Building & Extending For Zend_Tool
⢠Code to examine to learn more
ď´Zend_Tool_Framework
⢠Zend_Tool_Framework_Client & Zend_Tool_Framework_Registry
ď´Zend_Tool_Project
⢠Zend_Tool_Project_Provider_* (specifically DbAdapter, DbTable)
⢠Zend_Tool_Project_Context_* (specifically ControllerFile, ViewScriptFile,
DbTableFile)
ď´Zend_Tool_CodeGenerator_Php
⢠This is needed to generate, and regenerate code in most cases
32
33. Building & Extending For Zend_Tool
⢠Links to example files:
ď´(link here)
⢠Link to manual & good articles:
ď´http://framework.zend.com/manual/en/zend.tool.framework.html
ď´(more)
33