SlideShare a Scribd company logo
Using Zend_Tool to Establish Your Project's Skeleton DFW Apache LAMP Group presented by Jeremy Brown, ZCE 1 Feb 2010
Housekeeping
Who Am I? Jeremy Brown, Zend Certified Engineer (ZCE)   Have been using PHP since 1999 (PHP 3) Have been using Zend Framework since 2008 (version 1.0.4) Software Architect / Team Lead at Spear One (spearone.com)
Contact Information Blog: notmessenger.com Twitter: twitter.com/notmessenger Email: jeremy@notmessenger.com IRC: #zftalk and #dallasphp  (irc.freenode.net)
Where to find this presentation On my blog notmessenger.com/presentations Slideshare.net <insert link here>
How to provide feedback Via Joind.in http://joind.in/event/view/136
Your turn – who are you? How many of you have heard of Zend Framework before?
Your turn – who are you? How many of you have heard of Zend Framework before? How many of you have played with it a little bit?
Your turn – who are you? How many of you have heard of Zend Framework before? How many of you have played with it a little bit? How many of you use it in a project or on a regular basis?
Groundwork
What is Zend Framework An open source, object-oriented web application framework implemented in PHP 5 All components are fully object-oriented PHP 5 and are E_STRICT compliant Use-at-will architecture with loosely-coupled components and minimal interdependencies Provides individual components for many common requirements in web application development
So what is Zend_Tool? Zend_Tool is both rapid application development (RAD) tools as well as a framework for exposing your own set of tooling needs to the Zend_Tool user interface.
So what is Zend_Tool? Zend_Tool is both rapid application development (RAD) tools as well as a framework for exposing your own set of tooling needs to the Zend_Tool user interface. No, really, what is Zend_Tool?
Basic structure of a ZF application … OR…
Where’s the beef? Main Classes & APIs: Zend_Tool_Framework The component responsible for dispatching tooling requests Zend_Tool_Project The component responsible for exposing the “project specific” tooling capabilities Inspired by talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
Where’s the beef? Main Classes & APIs: Zend_Tool_Framework The component responsible for dispatching tooling requests Zend_Tool_Project The component responsible for exposing the “project specific” tooling capabilities And the gravy… Supporting Classes & APIs: Zend_CodeGenerator Zend_Reflection Inspired by talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
Zend_Tool_Framework
Zend_Tool_Framework sub-parts 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 From talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
Zend_Tool_Framework sub-parts 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 of Zend_Tool_Framework_Client_Console From talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
Zend_Tool_Framework sub-parts 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 From talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
Zend_Tool_Framework sub-parts Zend_Tool_Framework_Loader Responsibilities: Load files provided Search for classes defined that implement: Zend_Tool_Framework_Manifest_Interface Zend_Tool_Framework_Provider_Interface From talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
Zend_Tool_Framework sub-parts 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” From talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
Zend_Tool_Framework sub-parts 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, provider, or action ex: alternate names for each provider based on the command line naming scheme, OR short names (p for profile) From talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
Zend_Tool_Project
Zend_Tool_Project sub-parts 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_Project_Context object From talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
Zend_Tool_Project sub-parts Zend_Tool_Project_Context Responsibilities: The class most responsible for the “what” part of project modeling It is assigned to a Zend_Tool_Project_Profile_Resource object Example contexts: Controller file View script directory View script file Model file Action method … From talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
Putting it all together
Putting it all together Zend_Tool_Framework looks for providers, by default, on the include_path It recursivly iterates all include path directories and opens all files that end with “Manifest.php” or “Provider.php” All classes in these files are inspected if they implement either Zend_Tool_Framework_Provider_Interface  or Zend_Tool_Framework_Manifest_ProviderManifestable Zend_Tool_Project is consumed by Zend_Tool_Framework This allows Zend_Tool_Project to be only concerned with “project” problems This also allows Zend_Tool_Framework to focus on the problem of knowing which requests are good, and knowing how to dispatch said request Zend_Tool_Framework provides a client to the user
Additional Resources In relation to the information presented in this section http://framework.zend.com http://framework.zend.com/manual/en http://framework.zend.com/manual/1.10/en/zend.tool.html http://framework.zend.com/manual/1.10/en/zend.tool.framework.html http://framework.zend.com/manual/1.10/en/zend.tool.project.html http://framework.zend.com/manual/1.10/en/zend.codegenerator.html http://framework.zend.com/manual/1.10/en/zend.reflection.html http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
Setting things up
Install Zend Framework Download Zend Framework From website (http://framework.zend.com) SVN Zend Server From PEAR channel (http://pear.zfcampus.org/) Install it How? Where? For purpose of this presentation, have installed it at C:\ZendFramework-1.9.7
Prepare Zend_Tool
Understanding the CLI Tool /bin/zf.sh and /bin/zf.bat Operating system specific client wrappers Responsible for finding the proper php.exe, finding the zf.php file, and passing on the client request /bin/zf.php Responsible for: handling the understanding of your environment construction of proper include path passing what is provided on the command line to the proper library component for dispatching
Accessing the CLI Tool Two things have to be true: zf.sh/zf.bat is reachable from your system path. This is the ability to call ‘zf’ from anywhere on your command line, regardless of what your current working directory is. ZendFramework/library  is in your include path So how do we === true?
Make zf.sh/zf.bat reachable from system path Manual’s recommendation: Copy zf.sh/zf.bat and zf.php into the same directory as your PHP binary For *nix, usually: /usr/bin/ /usr/local/bin/ /usr/local/ZendServer/bin/ /Applications/ZendServer/bin For Windows, usually: C:\PHP C:\Program Files\ZendServer\bin C:\WAMP\PHP\bin
Make zf.sh/zf.bat reachable from system path My recommendation: Create an Alias to zf.sh/zf.bat For *nix: alias zf &quot;/usr/local/Zend/ZendFramework-1.9.7/bin/zf.sh&quot; alias zf &quot;/YOUR_PATH_HERE/bin/zf.sh&quot; For Windows: doskey zf=C:\ZENDFR~1.7\bin\zf.bat However…. On Windows, I could not get the arguments passed to  ‘zf’  to be passed along, so…. Ended up modifying the environment variable PATH to include C:\ZendFramework-1.9.7\bin
Add  ZendFramework/library  to include_path Manual’s recommendation: Determine what your current include_path value is and add the contents of  ZendFramework/library  to one of these locations Alternative option to above: For *nix: In a location included in your current include_path, create a symbolic link to the location of  ZendFramework/library For Windows: Modify the environment variable PATH to include C:\PATH_TO_ZENDFRAMEWORK\bin Alter your php.ini file and modify include_path directive to include C:\PATH_TO_ZENDFRAMEWORK\library
Add  ZendFramework/library  to include_path My recommendation: Use special environment variable(s) to tell zf.php the location of  ZendFramework/library They are: ZEND_TOOL_INCLUDE_PATH_PREPEND Will prepend the value of this environment variable to the system (php.ini) include_path before loading the client ZEND_TOOL_INCLUDE_PATH Completely replaces the system include_path with the one specified How to do this: For *nix: setenv ZEND_TOOL_INCLUDE_PATH_PREPEND /usr/local/Zend/ZendFramework-1.9.7/library/ For Windows: set ZEND_TOOL_INCLUDE_PATH_PREPEND=C:\ZENDFR~1.7\library
Other settable environment variables ZF_HOME ZF_STORAGE_DIR ZF_CONFIG_FILE ZF_INCLUDE_PATH ZF_INCLUDE_PATH_PREPEND Can be found at http://framework.zend.com/manual/en/zend.tool.usage.cli.html
Did I set it up correctly? To verify that the previous steps worked correctly, enter  ‘zf’  at the command line.  Should expect to see something similar to:
Additional Resources In relation to the information presented in this section http://framework.zend.com/manual/1.10/en/zend.tool.framework.html http://framework.zend.com/manual/1.10/en/zend.tool.usage.cli.html http://framework.zend.com/manual/1.10/en/zend.tool.extending.html http://en.wikipedia.org/wiki/Alias_%28command%29 http://www.unix.com/windows-dos-issues-discussions/74664-what-dos-equivalent-alias-command.html
Enough with the setup – I’m here for some coding!
Few basic things zf --help zf show version zf show version zf show version -n 0 zf show version.major-part zf show version -m minor -n 0
Create project Provide a path: zf create project demo Be prompted for path: zf create project
Create project Provide a path: zf create project demo Be prompted for path: zf create project Can now run: zf show project zf show profile
Create Controller Provide a controller name: zf create controller <controllername> Be prompted for a controller name: zf create controller
Create Controller Actions zf create action <actioname> <controllername> Will throw a Fatal Error if <controllername> does not exist
Create views zf create view <controllername> <actionname> <actionname> is really only for the name of the View Script – a new action is NOT created in the controller
Additional Resources In relation to the information presented in this section http://framework.zend.com/manual/en/zend.tool.project.create-a-project.html http://framework.zend.com/manual/en/zend.tool.project.providers.html http://ralphschindler.com/wiki/index.php/Using_Zend_Tool
Extending Zend_Tool
How Zend_Tool finds your Providers Remember that: Zend_Tool_Framework looks for providers, by default, on the include_path It recursivly iterates all include path directories and opens all files that end with “Manifest.php” or “Provider.php” All classes in these files are inspected if they implement either Zend_Tool_Framework_Provider_Interface  or Zend_Tool_Framework_Manifest_ProviderManifestable
How Zend_Tool finds your Providers The following naming rules apply on how you can access the providers that were found by the IncludePathLoader: The last part of your classname split by underscore is used for the provider name, e.g. “My_Provider_Hello” leads to your provider being accessible by the name “hello” If your provider has a method  getName()  it will be used instead of the previous method to determine the name If your provider has “Provider” as suffix, e.g. it is called “My_HelloProvider”, it will be stripped from the name so that the provider will be called “hello”. Note: The IncludePathLoader does not follow symlinks.  This means you cannot link provider functionality into your include paths, they have to be physically present in the include paths.
Example Custom Provider
Minimum code needed… /My/Provider/Slide54Provider.php
…but we really need some more The previous example illustrates being able to make your newly-created custom provider to be seen by Zend_Tool_Framework, but it really isn’t able to expose any Provider capabilities. What you need instead is: /My/Provider/Slide55Provider.php
Provide alternate name for Provider /My/Provider/Slide56Provider.php
Example Custom Manifest
Minimum code needed /My/Manifest/Slide58Manifest.php
Let’s do more with Providers
Passing variables to a Provider /My/Provider/Slide60.php Examples of how to call this provider: zf say slide60 zf say slide60 Jason zf say slide60 --name Jason
Prompt user for input /My/Provider/Slide61.php
Pretendability /My/Provider/Slide62.php Examples of how to call this provider: zf say slide62 zf --pretend say slide62
Verbose /My/Provider/Slide63.php Examples of how to call this provider: zf say slide63 zf --verbose say slide63
Debug /My/Provider/Slide64.php Examples of how to call this provider: zf say slide64 zf --debug say slide64
Multiple arguments /My/Provider/Slide65.php
Additional Resources In relation to the information presented in this section http://framework.zend.com/manual/en/zend.tool.extending.html http://framework.zend.com/manual/en/zend.tool.framework.writing-providers.html
Customizing Zend_Tool Console Client
Customizing Zend_Tool Console Client Zend_Tool_Framework allows developers to store information, provider-specific configuration values, and custom files in a special location on the developers machine. Items of discussion: Home Directory Local Storage User Configuration
Additional Resources In relation to the information presented in this section http://framework.zend.com/manual/1.10/en/zend.tool.framework.extending.html http://framework.zend.com/manual/en/zend.tool.framework.writing-providers.html
Putting our Providers to work
Keep profile up-to-date $this->_loadProfile(); $this->_storeProfile();
Context Can extend Zend_Tool_Project_Context_Filesystem_File and Zend_Tool_Project_Context_Filesystem_Directory to create context classes. $profile = $this->_loadProfile(); $modelsDirectory = $profile->search('ModelsDirectory'); $modelFile = $modelsDirectory->createResource('ModelFile'); $modelFile->getContext()->setModelName($name); Excerpts from Zend Webinar presented by Ralph Schindler of Zend http://www.zend.com/en/webinar/framework/webinar-zend-tool-20090630.flv
Zend_CodeGenerator Excerpts from Zend Webinar presented by Ralph Schindler of Zend http://www.zend.com/en/webinar/framework/webinar-zend-tool-20090630.flv
Integration with Zend_Application Excerpts from Zend Webinar presented by Ralph Schindler of Zend http://www.zend.com/en/webinar/framework/webinar-zend-tool-20090630.flv
Additional Resources In relation to the information presented in this section http://framework.zend.com/manual/en/zend.tool.extending.html http://www.zend.com/en/webinar/framework/webinar-zend-tool-20090630.flv
Where do things go from here?
Known plans
Roadmap Zend Framework 1.10 offers Model Provider Form Provider DbTable Provider DbAdapter configuration Layout enabling and creation Custom Profiles Improved Module Provider … and more! In the works Web interface Better documentation Have hopes for Apache configuration code generator
Using for your own needs
The sky’s the limit Don’t have to use it for just a “project” How Spear One has begun, and plans, on using Zend_Tool
Improving Zend_Tool
Public Service Announcement Play with it and use it Submit bugs and feature requests http://framework.zend.com/issues/browse/ZF/component/10380 Get involved in the community Write a blog post Visit #zftalk on irc.freenode.net Become a contributor Fix bugs Implement new feature set Improve documentation
Additional Resources In relation to the information presented in this section http://framework.zend.com/issues/browse/ZF/component/10380 http://framework.zend.com/issues/browse/ZF-7940 http://ralphschindler.com/wiki/index.php/Using_Zend_Tool
Thank you!
Contact Information Blog: notmessenger.com Twitter: twitter.com/notmessenger Email: jeremy@notmessenger.com IRC: #zftalk and #dallasphp Where to find presentation notmessenger.com/presentations <insert slideshare.net link here> Please rate this talk on Joind.in http://joind.in/event/view/136

More Related Content

KEY
Extending Zend_Tool
PPT
2007 Zend Con Mvc Edited Irmantas
KEY
A Conversation About REST
PPT
Zend Framework Introduction
PDF
Deprecated: Foundations of Zend Framework 2
PPTX
PHP on IBM i Tutorial
PDF
A quick start on Zend Framework 2
PDF
Organinzing Your PHP Projects (2010 Memphis PHP)
Extending Zend_Tool
2007 Zend Con Mvc Edited Irmantas
A Conversation About REST
Zend Framework Introduction
Deprecated: Foundations of Zend Framework 2
PHP on IBM i Tutorial
A quick start on Zend Framework 2
Organinzing Your PHP Projects (2010 Memphis PHP)

What's hot (10)

PDF
The Solar Framework for PHP 5 (2010 Confoo)
ODP
Java Code Generation for Productivity
PDF
.NET Core, ASP.NET Core Course, Session 3
PDF
Zend Framework 2 quick start
PDF
Zend Framework 2 Components
PDF
Action-Domain-Responder: A Refinement of MVC
PDF
Java Enterprise Edition
PPTX
Hibernate
PPT
Zend Framework 2
PPT
Zend Framework
The Solar Framework for PHP 5 (2010 Confoo)
Java Code Generation for Productivity
.NET Core, ASP.NET Core Course, Session 3
Zend Framework 2 quick start
Zend Framework 2 Components
Action-Domain-Responder: A Refinement of MVC
Java Enterprise Edition
Hibernate
Zend Framework 2
Zend Framework
Ad

Viewers also liked (20)

PDF
10 windows 7 commands every administrator should know
PDF
ClickandBuy booklet
PPT
Waardeverkenner
PPT
8 7 Nrbb Flow
PDF
Esomar Beijing Preso
PDF
C.e. dic. 2015. ultima adecuacion al convenio de pruebas
PPTX
Tess Of The D’Urbervilles
PPT
Inleiding CV-ketelkeuring: "Last of Must"
PDF
Oracle networking listener
PPSX
PDF
2015 12 efw sap functional short
PDF
PPTX
Energiebesparing en het Activiteitenbesluit
PDF
Je instagram vreden milijarde dolarjev?_Marketing Magazin_maj2012_st.372_str.16
PPTX
Advanced Excel, Day 4
PDF
Bouyn Brochurev1
PPTX
10 windows 7 commands every administrator should know
ClickandBuy booklet
Waardeverkenner
8 7 Nrbb Flow
Esomar Beijing Preso
C.e. dic. 2015. ultima adecuacion al convenio de pruebas
Tess Of The D’Urbervilles
Inleiding CV-ketelkeuring: "Last of Must"
Oracle networking listener
2015 12 efw sap functional short
Energiebesparing en het Activiteitenbesluit
Je instagram vreden milijarde dolarjev?_Marketing Magazin_maj2012_st.372_str.16
Advanced Excel, Day 4
Bouyn Brochurev1
Ad

Similar to Using Zend_Tool to Establish Your Project's Skeleton (20)

KEY
Zend_Tool: Practical use and Extending
PPT
Zend_Tool: Rapid Application Development with Zend Framework
PPT
Zend Framework 1.8 Features Webinar
PPTX
MVC Frameworks for building PHP Web Applications
ODP
Zero to Zend Framework in 10 minutes
PDF
Getting started-with-zend-framework
PDF
Quick start on Zend Framework 2
PPTX
Zend Framework Workshop
PPT
PPT
Greenathan
PPT
Greenathan
PPT
PPT
PPT
werwer
PPT
PPT
PPT
sdfsdf
PPT
PPT
PPT
scenary
Zend_Tool: Practical use and Extending
Zend_Tool: Rapid Application Development with Zend Framework
Zend Framework 1.8 Features Webinar
MVC Frameworks for building PHP Web Applications
Zero to Zend Framework in 10 minutes
Getting started-with-zend-framework
Quick start on Zend Framework 2
Zend Framework Workshop
Greenathan
Greenathan
werwer
sdfsdf
scenary

Recently uploaded (20)

PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
KodekX | Application Modernization Development
PPTX
Cloud computing and distributed systems.
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Big Data Technologies - Introduction.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPT
Teaching material agriculture food technology
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
Chapter 3 Spatial Domain Image Processing.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Per capita expenditure prediction using model stacking based on satellite ima...
KodekX | Application Modernization Development
Cloud computing and distributed systems.
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Programs and apps: productivity, graphics, security and other tools
Diabetes mellitus diagnosis method based random forest with bat algorithm
Big Data Technologies - Introduction.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Teaching material agriculture food technology
Building Integrated photovoltaic BIPV_UPV.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
The Rise and Fall of 3GPP – Time for a Sabbatical?

Using Zend_Tool to Establish Your Project's Skeleton

  • 1. Using Zend_Tool to Establish Your Project's Skeleton DFW Apache LAMP Group presented by Jeremy Brown, ZCE 1 Feb 2010
  • 3. Who Am I? Jeremy Brown, Zend Certified Engineer (ZCE) Have been using PHP since 1999 (PHP 3) Have been using Zend Framework since 2008 (version 1.0.4) Software Architect / Team Lead at Spear One (spearone.com)
  • 4. Contact Information Blog: notmessenger.com Twitter: twitter.com/notmessenger Email: jeremy@notmessenger.com IRC: #zftalk and #dallasphp (irc.freenode.net)
  • 5. Where to find this presentation On my blog notmessenger.com/presentations Slideshare.net <insert link here>
  • 6. How to provide feedback Via Joind.in http://joind.in/event/view/136
  • 7. Your turn – who are you? How many of you have heard of Zend Framework before?
  • 8. Your turn – who are you? How many of you have heard of Zend Framework before? How many of you have played with it a little bit?
  • 9. Your turn – who are you? How many of you have heard of Zend Framework before? How many of you have played with it a little bit? How many of you use it in a project or on a regular basis?
  • 11. What is Zend Framework An open source, object-oriented web application framework implemented in PHP 5 All components are fully object-oriented PHP 5 and are E_STRICT compliant Use-at-will architecture with loosely-coupled components and minimal interdependencies Provides individual components for many common requirements in web application development
  • 12. So what is Zend_Tool? Zend_Tool is both rapid application development (RAD) tools as well as a framework for exposing your own set of tooling needs to the Zend_Tool user interface.
  • 13. So what is Zend_Tool? Zend_Tool is both rapid application development (RAD) tools as well as a framework for exposing your own set of tooling needs to the Zend_Tool user interface. No, really, what is Zend_Tool?
  • 14. Basic structure of a ZF application … OR…
  • 15. Where’s the beef? Main Classes & APIs: Zend_Tool_Framework The component responsible for dispatching tooling requests Zend_Tool_Project The component responsible for exposing the “project specific” tooling capabilities Inspired by talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
  • 16. Where’s the beef? Main Classes & APIs: Zend_Tool_Framework The component responsible for dispatching tooling requests Zend_Tool_Project The component responsible for exposing the “project specific” tooling capabilities And the gravy… Supporting Classes & APIs: Zend_CodeGenerator Zend_Reflection Inspired by talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
  • 18. Zend_Tool_Framework sub-parts 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 From talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
  • 19. Zend_Tool_Framework sub-parts 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 of Zend_Tool_Framework_Client_Console From talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
  • 20. Zend_Tool_Framework sub-parts 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 From talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
  • 21. Zend_Tool_Framework sub-parts Zend_Tool_Framework_Loader Responsibilities: Load files provided Search for classes defined that implement: Zend_Tool_Framework_Manifest_Interface Zend_Tool_Framework_Provider_Interface From talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
  • 22. Zend_Tool_Framework sub-parts 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” From talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
  • 23. Zend_Tool_Framework sub-parts 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, provider, or action ex: alternate names for each provider based on the command line naming scheme, OR short names (p for profile) From talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
  • 25. Zend_Tool_Project sub-parts 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_Project_Context object From talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
  • 26. Zend_Tool_Project sub-parts Zend_Tool_Project_Context Responsibilities: The class most responsible for the “what” part of project modeling It is assigned to a Zend_Tool_Project_Profile_Resource object Example contexts: Controller file View script directory View script file Model file Action method … From talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
  • 27. Putting it all together
  • 28. Putting it all together Zend_Tool_Framework looks for providers, by default, on the include_path It recursivly iterates all include path directories and opens all files that end with “Manifest.php” or “Provider.php” All classes in these files are inspected if they implement either Zend_Tool_Framework_Provider_Interface or Zend_Tool_Framework_Manifest_ProviderManifestable Zend_Tool_Project is consumed by Zend_Tool_Framework This allows Zend_Tool_Project to be only concerned with “project” problems This also allows Zend_Tool_Framework to focus on the problem of knowing which requests are good, and knowing how to dispatch said request Zend_Tool_Framework provides a client to the user
  • 29. Additional Resources In relation to the information presented in this section http://framework.zend.com http://framework.zend.com/manual/en http://framework.zend.com/manual/1.10/en/zend.tool.html http://framework.zend.com/manual/1.10/en/zend.tool.framework.html http://framework.zend.com/manual/1.10/en/zend.tool.project.html http://framework.zend.com/manual/1.10/en/zend.codegenerator.html http://framework.zend.com/manual/1.10/en/zend.reflection.html http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
  • 31. Install Zend Framework Download Zend Framework From website (http://framework.zend.com) SVN Zend Server From PEAR channel (http://pear.zfcampus.org/) Install it How? Where? For purpose of this presentation, have installed it at C:\ZendFramework-1.9.7
  • 33. Understanding the CLI Tool /bin/zf.sh and /bin/zf.bat Operating system specific client wrappers Responsible for finding the proper php.exe, finding the zf.php file, and passing on the client request /bin/zf.php Responsible for: handling the understanding of your environment construction of proper include path passing what is provided on the command line to the proper library component for dispatching
  • 34. Accessing the CLI Tool Two things have to be true: zf.sh/zf.bat is reachable from your system path. This is the ability to call ‘zf’ from anywhere on your command line, regardless of what your current working directory is. ZendFramework/library is in your include path So how do we === true?
  • 35. Make zf.sh/zf.bat reachable from system path Manual’s recommendation: Copy zf.sh/zf.bat and zf.php into the same directory as your PHP binary For *nix, usually: /usr/bin/ /usr/local/bin/ /usr/local/ZendServer/bin/ /Applications/ZendServer/bin For Windows, usually: C:\PHP C:\Program Files\ZendServer\bin C:\WAMP\PHP\bin
  • 36. Make zf.sh/zf.bat reachable from system path My recommendation: Create an Alias to zf.sh/zf.bat For *nix: alias zf &quot;/usr/local/Zend/ZendFramework-1.9.7/bin/zf.sh&quot; alias zf &quot;/YOUR_PATH_HERE/bin/zf.sh&quot; For Windows: doskey zf=C:\ZENDFR~1.7\bin\zf.bat However…. On Windows, I could not get the arguments passed to ‘zf’ to be passed along, so…. Ended up modifying the environment variable PATH to include C:\ZendFramework-1.9.7\bin
  • 37. Add ZendFramework/library to include_path Manual’s recommendation: Determine what your current include_path value is and add the contents of ZendFramework/library to one of these locations Alternative option to above: For *nix: In a location included in your current include_path, create a symbolic link to the location of ZendFramework/library For Windows: Modify the environment variable PATH to include C:\PATH_TO_ZENDFRAMEWORK\bin Alter your php.ini file and modify include_path directive to include C:\PATH_TO_ZENDFRAMEWORK\library
  • 38. Add ZendFramework/library to include_path My recommendation: Use special environment variable(s) to tell zf.php the location of ZendFramework/library They are: ZEND_TOOL_INCLUDE_PATH_PREPEND Will prepend the value of this environment variable to the system (php.ini) include_path before loading the client ZEND_TOOL_INCLUDE_PATH Completely replaces the system include_path with the one specified How to do this: For *nix: setenv ZEND_TOOL_INCLUDE_PATH_PREPEND /usr/local/Zend/ZendFramework-1.9.7/library/ For Windows: set ZEND_TOOL_INCLUDE_PATH_PREPEND=C:\ZENDFR~1.7\library
  • 39. Other settable environment variables ZF_HOME ZF_STORAGE_DIR ZF_CONFIG_FILE ZF_INCLUDE_PATH ZF_INCLUDE_PATH_PREPEND Can be found at http://framework.zend.com/manual/en/zend.tool.usage.cli.html
  • 40. Did I set it up correctly? To verify that the previous steps worked correctly, enter ‘zf’ at the command line. Should expect to see something similar to:
  • 41. Additional Resources In relation to the information presented in this section http://framework.zend.com/manual/1.10/en/zend.tool.framework.html http://framework.zend.com/manual/1.10/en/zend.tool.usage.cli.html http://framework.zend.com/manual/1.10/en/zend.tool.extending.html http://en.wikipedia.org/wiki/Alias_%28command%29 http://www.unix.com/windows-dos-issues-discussions/74664-what-dos-equivalent-alias-command.html
  • 42. Enough with the setup – I’m here for some coding!
  • 43. Few basic things zf --help zf show version zf show version zf show version -n 0 zf show version.major-part zf show version -m minor -n 0
  • 44. Create project Provide a path: zf create project demo Be prompted for path: zf create project
  • 45. Create project Provide a path: zf create project demo Be prompted for path: zf create project Can now run: zf show project zf show profile
  • 46. Create Controller Provide a controller name: zf create controller <controllername> Be prompted for a controller name: zf create controller
  • 47. Create Controller Actions zf create action <actioname> <controllername> Will throw a Fatal Error if <controllername> does not exist
  • 48. Create views zf create view <controllername> <actionname> <actionname> is really only for the name of the View Script – a new action is NOT created in the controller
  • 49. Additional Resources In relation to the information presented in this section http://framework.zend.com/manual/en/zend.tool.project.create-a-project.html http://framework.zend.com/manual/en/zend.tool.project.providers.html http://ralphschindler.com/wiki/index.php/Using_Zend_Tool
  • 51. How Zend_Tool finds your Providers Remember that: Zend_Tool_Framework looks for providers, by default, on the include_path It recursivly iterates all include path directories and opens all files that end with “Manifest.php” or “Provider.php” All classes in these files are inspected if they implement either Zend_Tool_Framework_Provider_Interface or Zend_Tool_Framework_Manifest_ProviderManifestable
  • 52. How Zend_Tool finds your Providers The following naming rules apply on how you can access the providers that were found by the IncludePathLoader: The last part of your classname split by underscore is used for the provider name, e.g. “My_Provider_Hello” leads to your provider being accessible by the name “hello” If your provider has a method getName() it will be used instead of the previous method to determine the name If your provider has “Provider” as suffix, e.g. it is called “My_HelloProvider”, it will be stripped from the name so that the provider will be called “hello”. Note: The IncludePathLoader does not follow symlinks. This means you cannot link provider functionality into your include paths, they have to be physically present in the include paths.
  • 54. Minimum code needed… /My/Provider/Slide54Provider.php
  • 55. …but we really need some more The previous example illustrates being able to make your newly-created custom provider to be seen by Zend_Tool_Framework, but it really isn’t able to expose any Provider capabilities. What you need instead is: /My/Provider/Slide55Provider.php
  • 56. Provide alternate name for Provider /My/Provider/Slide56Provider.php
  • 58. Minimum code needed /My/Manifest/Slide58Manifest.php
  • 59. Let’s do more with Providers
  • 60. Passing variables to a Provider /My/Provider/Slide60.php Examples of how to call this provider: zf say slide60 zf say slide60 Jason zf say slide60 --name Jason
  • 61. Prompt user for input /My/Provider/Slide61.php
  • 62. Pretendability /My/Provider/Slide62.php Examples of how to call this provider: zf say slide62 zf --pretend say slide62
  • 63. Verbose /My/Provider/Slide63.php Examples of how to call this provider: zf say slide63 zf --verbose say slide63
  • 64. Debug /My/Provider/Slide64.php Examples of how to call this provider: zf say slide64 zf --debug say slide64
  • 66. Additional Resources In relation to the information presented in this section http://framework.zend.com/manual/en/zend.tool.extending.html http://framework.zend.com/manual/en/zend.tool.framework.writing-providers.html
  • 68. Customizing Zend_Tool Console Client Zend_Tool_Framework allows developers to store information, provider-specific configuration values, and custom files in a special location on the developers machine. Items of discussion: Home Directory Local Storage User Configuration
  • 69. Additional Resources In relation to the information presented in this section http://framework.zend.com/manual/1.10/en/zend.tool.framework.extending.html http://framework.zend.com/manual/en/zend.tool.framework.writing-providers.html
  • 71. Keep profile up-to-date $this->_loadProfile(); $this->_storeProfile();
  • 72. Context Can extend Zend_Tool_Project_Context_Filesystem_File and Zend_Tool_Project_Context_Filesystem_Directory to create context classes. $profile = $this->_loadProfile(); $modelsDirectory = $profile->search('ModelsDirectory'); $modelFile = $modelsDirectory->createResource('ModelFile'); $modelFile->getContext()->setModelName($name); Excerpts from Zend Webinar presented by Ralph Schindler of Zend http://www.zend.com/en/webinar/framework/webinar-zend-tool-20090630.flv
  • 73. Zend_CodeGenerator Excerpts from Zend Webinar presented by Ralph Schindler of Zend http://www.zend.com/en/webinar/framework/webinar-zend-tool-20090630.flv
  • 74. Integration with Zend_Application Excerpts from Zend Webinar presented by Ralph Schindler of Zend http://www.zend.com/en/webinar/framework/webinar-zend-tool-20090630.flv
  • 75. Additional Resources In relation to the information presented in this section http://framework.zend.com/manual/en/zend.tool.extending.html http://www.zend.com/en/webinar/framework/webinar-zend-tool-20090630.flv
  • 76. Where do things go from here?
  • 78. Roadmap Zend Framework 1.10 offers Model Provider Form Provider DbTable Provider DbAdapter configuration Layout enabling and creation Custom Profiles Improved Module Provider … and more! In the works Web interface Better documentation Have hopes for Apache configuration code generator
  • 79. Using for your own needs
  • 80. The sky’s the limit Don’t have to use it for just a “project” How Spear One has begun, and plans, on using Zend_Tool
  • 82. Public Service Announcement Play with it and use it Submit bugs and feature requests http://framework.zend.com/issues/browse/ZF/component/10380 Get involved in the community Write a blog post Visit #zftalk on irc.freenode.net Become a contributor Fix bugs Implement new feature set Improve documentation
  • 83. Additional Resources In relation to the information presented in this section http://framework.zend.com/issues/browse/ZF/component/10380 http://framework.zend.com/issues/browse/ZF-7940 http://ralphschindler.com/wiki/index.php/Using_Zend_Tool
  • 85. Contact Information Blog: notmessenger.com Twitter: twitter.com/notmessenger Email: jeremy@notmessenger.com IRC: #zftalk and #dallasphp Where to find presentation notmessenger.com/presentations <insert slideshare.net link here> Please rate this talk on Joind.in http://joind.in/event/view/136