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? <ul><li>Jeremy Brown, Zend Certified Engineer (ZCE)   </li></ul><ul><li>Have been using PHP since 1999 (PHP 3) <...
Contact Information <ul><li>Blog: notmessenger.com </li></ul><ul><li>Twitter: twitter.com/notmessenger </li></ul><ul><li>E...
Where to find this presentation <ul><li>On my blog </li></ul><ul><ul><li>notmessenger.com/presentations </li></ul></ul><ul...
How to provide feedback <ul><li>Via Joind.in </li></ul><ul><ul><li>http://joind.in/event/view/136 </li></ul></ul>
Your turn – who are you? <ul><li>How many of you have heard of Zend Framework before? </li></ul>
Your turn – who are you? <ul><li>How many of you have heard of Zend Framework before? </li></ul><ul><li>How many of you ha...
Your turn – who are you? <ul><li>How many of you have heard of Zend Framework before? </li></ul><ul><li>How many of you ha...
Groundwork
What is Zend Framework <ul><li>An open source, object-oriented web application framework implemented in PHP 5 </li></ul><u...
So what is Zend_Tool? <ul><li>Zend_Tool is both rapid application development (RAD) tools as well as a framework for expos...
So what is Zend_Tool? <ul><li>Zend_Tool is both rapid application development (RAD) tools as well as a framework for expos...
Basic structure of a ZF application … OR…
Where’s the beef? <ul><li>Main Classes & APIs: </li></ul><ul><ul><li>Zend_Tool_Framework </li></ul></ul><ul><ul><ul><li>Th...
Where’s the beef? <ul><li>Main Classes & APIs: </li></ul><ul><ul><li>Zend_Tool_Framework </li></ul></ul><ul><ul><ul><li>Th...
Zend_Tool_Framework
Zend_Tool_Framework sub-parts <ul><li>Zend_Tool_Framework </li></ul><ul><ul><li>Dispatch-style framework, designed to abst...
Zend_Tool_Framework sub-parts <ul><li>Zend_Tool_Framework_Client </li></ul><ul><ul><li>Responsibilities: </li></ul></ul><u...
Zend_Tool_Framework sub-parts <ul><li>Zend_Tool_Framework_Client_Storage & Zend_Tool_Framework_Client_Config </li></ul><ul...
Zend_Tool_Framework sub-parts <ul><li>Zend_Tool_Framework_Loader </li></ul><ul><ul><li>Responsibilities: </li></ul></ul><u...
Zend_Tool_Framework sub-parts <ul><li>Zend_Tool_Framework_Provider & Provider Registry </li></ul><ul><ul><li>Responsibilit...
Zend_Tool_Framework sub-parts <ul><li>Zend_Tool_Framework_Manifest & Manifest Repository </li></ul><ul><ul><li>Responsibil...
Zend_Tool_Project
Zend_Tool_Project sub-parts <ul><li>Zend_Tool_Project_Profile </li></ul><ul><ul><li>Responsibilities: </li></ul></ul><ul><...
Zend_Tool_Project sub-parts <ul><li>Zend_Tool_Project_Context </li></ul><ul><ul><li>Responsibilities: </li></ul></ul><ul><...
Putting it all together
Putting it all together <ul><li>Zend_Tool_Framework looks for providers, by default, on the include_path </li></ul><ul><ul...
Additional Resources <ul><li>In relation to the information presented in this section </li></ul><ul><li>http://framework.z...
Setting things up
Install Zend Framework <ul><li>Download Zend Framework </li></ul><ul><ul><li>From website (http://framework.zend.com) </li...
Prepare Zend_Tool
Understanding the CLI Tool <ul><li>/bin/zf.sh and /bin/zf.bat </li></ul><ul><ul><li>Operating system specific client wrapp...
Accessing the CLI Tool <ul><li>Two things have to be true: </li></ul><ul><ul><li>zf.sh/zf.bat is reachable from your syste...
Make zf.sh/zf.bat reachable from system path <ul><li>Manual’s recommendation: </li></ul><ul><ul><li>Copy zf.sh/zf.bat and ...
Make zf.sh/zf.bat reachable from system path <ul><li>My recommendation: </li></ul><ul><ul><li>Create an Alias to zf.sh/zf....
Add  ZendFramework/library  to include_path <ul><li>Manual’s recommendation: </li></ul><ul><ul><li>Determine what your cur...
Add  ZendFramework/library  to include_path <ul><li>My recommendation: </li></ul><ul><ul><li>Use special environment varia...
Other settable environment variables <ul><li>ZF_HOME </li></ul><ul><li>ZF_STORAGE_DIR </li></ul><ul><li>ZF_CONFIG_FILE </l...
Did I set it up correctly? <ul><li>To verify that the previous steps worked correctly, enter  ‘zf’  at the command line.  ...
Additional Resources <ul><li>In relation to the information presented in this section </li></ul><ul><li>http://framework.z...
Enough with the setup – I’m here for some coding!
Few basic things <ul><li>zf --help </li></ul><ul><li>zf show version </li></ul><ul><li>zf show version </li></ul><ul><li>z...
Create project <ul><li>Provide a path: </li></ul><ul><ul><li>zf create project demo </li></ul></ul><ul><li>Be prompted for...
Create project <ul><li>Provide a path: </li></ul><ul><ul><li>zf create project demo </li></ul></ul><ul><li>Be prompted for...
Create Controller <ul><li>Provide a controller name: </li></ul><ul><ul><li>zf create controller <controllername> </li></ul...
Create Controller Actions <ul><li>zf create action <actioname> <controllername> </li></ul><ul><ul><li>Will throw a Fatal E...
Create views <ul><li>zf create view <controllername> <actionname> </li></ul><ul><ul><li><actionname> is really only for th...
Additional Resources <ul><li>In relation to the information presented in this section </li></ul><ul><li>http://framework.z...
Extending Zend_Tool
How Zend_Tool finds your Providers <ul><li>Remember that: </li></ul><ul><li>Zend_Tool_Framework looks for providers, by de...
How Zend_Tool finds your Providers <ul><li>The following naming rules apply on how you can access the providers that were ...
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...
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 <ul><li>Examples of how to call this provider: </li></ul><ul><ul>...
Prompt user for input /My/Provider/Slide61.php
Pretendability /My/Provider/Slide62.php <ul><li>Examples of how to call this provider: </li></ul><ul><ul><li>zf say slide6...
Verbose /My/Provider/Slide63.php <ul><li>Examples of how to call this provider: </li></ul><ul><ul><li>zf say slide63 </li>...
Debug /My/Provider/Slide64.php <ul><li>Examples of how to call this provider: </li></ul><ul><ul><li>zf say slide64 </li></...
Multiple arguments /My/Provider/Slide65.php
Additional Resources <ul><li>In relation to the information presented in this section </li></ul><ul><li>http://framework.z...
Customizing Zend_Tool Console Client
Customizing Zend_Tool Console Client <ul><li>Zend_Tool_Framework allows developers to store information, provider-specific...
Additional Resources <ul><li>In relation to the information presented in this section </li></ul><ul><li>http://framework.z...
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 ...
Zend_CodeGenerator Excerpts from Zend Webinar presented by Ralph Schindler of Zend http://www.zend.com/en/webinar/framewor...
Integration with Zend_Application Excerpts from Zend Webinar presented by Ralph Schindler of Zend http://www.zend.com/en/w...
Additional Resources <ul><li>In relation to the information presented in this section </li></ul><ul><li>http://framework.z...
Where do things go from here?
Known plans
Roadmap <ul><li>Zend Framework 1.10 offers </li></ul><ul><ul><li>Model Provider </li></ul></ul><ul><ul><li>Form Provider <...
Using for your own needs
The sky’s the limit <ul><li>Don’t have to use it for just a “project” </li></ul><ul><li>How Spear One has begun, and plans...
Improving Zend_Tool
Public Service Announcement <ul><li>Play with it and use it </li></ul><ul><li>Submit bugs and feature requests </li></ul><...
Additional Resources <ul><li>In relation to the information presented in this section </li></ul><ul><li>http://framework.z...
Thank you!
Contact Information <ul><li>Blog: notmessenger.com </li></ul><ul><li>Twitter: twitter.com/notmessenger </li></ul><ul><li>E...
Upcoming SlideShare
Loading in...5
×

Using Zend_Tool to Establish Your Project's Skeleton

3,805

Published on

User Group presentation titled "Using Zend_Tool to Establish Your Project's Skeleton"

Event information can be found at: http://www.meetup.com/DFW-Apache-LAMP/calendar/11819226/

Published in: Technology
0 Comments
9 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,805
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
0
Comments
0
Likes
9
Embeds 0
No embeds

No notes for slide

Using Zend_Tool to Establish Your Project's Skeleton

  1. 1. Using Zend_Tool to Establish Your Project's Skeleton DFW Apache LAMP Group presented by Jeremy Brown, ZCE 1 Feb 2010
  2. 2. Housekeeping
  3. 3. Who Am I? <ul><li>Jeremy Brown, Zend Certified Engineer (ZCE) </li></ul><ul><li>Have been using PHP since 1999 (PHP 3) </li></ul><ul><li>Have been using Zend Framework since 2008 (version 1.0.4) </li></ul><ul><li>Software Architect / Team Lead at Spear One (spearone.com) </li></ul>
  4. 4. Contact Information <ul><li>Blog: notmessenger.com </li></ul><ul><li>Twitter: twitter.com/notmessenger </li></ul><ul><li>Email: jeremy@notmessenger.com </li></ul><ul><li>IRC: #zftalk and #dallasphp (irc.freenode.net) </li></ul>
  5. 5. Where to find this presentation <ul><li>On my blog </li></ul><ul><ul><li>notmessenger.com/presentations </li></ul></ul><ul><li>Slideshare.net </li></ul><ul><ul><li><insert link here> </li></ul></ul>
  6. 6. How to provide feedback <ul><li>Via Joind.in </li></ul><ul><ul><li>http://joind.in/event/view/136 </li></ul></ul>
  7. 7. Your turn – who are you? <ul><li>How many of you have heard of Zend Framework before? </li></ul>
  8. 8. Your turn – who are you? <ul><li>How many of you have heard of Zend Framework before? </li></ul><ul><li>How many of you have played with it a little bit? </li></ul>
  9. 9. Your turn – who are you? <ul><li>How many of you have heard of Zend Framework before? </li></ul><ul><li>How many of you have played with it a little bit? </li></ul><ul><li>How many of you use it in a project or on a regular basis? </li></ul>
  10. 10. Groundwork
  11. 11. What is Zend Framework <ul><li>An open source, object-oriented web application framework implemented in PHP 5 </li></ul><ul><li>All components are fully object-oriented PHP 5 and are E_STRICT compliant </li></ul><ul><li>Use-at-will architecture with loosely-coupled components and minimal interdependencies </li></ul><ul><li>Provides individual components for many common requirements in web application development </li></ul>
  12. 12. So what is Zend_Tool? <ul><li>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. </li></ul>
  13. 13. So what is Zend_Tool? <ul><li>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. </li></ul><ul><li>No, really, what is Zend_Tool? </li></ul>
  14. 14. Basic structure of a ZF application … OR…
  15. 15. Where’s the beef? <ul><li>Main Classes & APIs: </li></ul><ul><ul><li>Zend_Tool_Framework </li></ul></ul><ul><ul><ul><li>The component responsible for dispatching tooling requests </li></ul></ul></ul><ul><ul><li>Zend_Tool_Project </li></ul></ul><ul><ul><ul><li>The component responsible for exposing the “project specific” tooling capabilities </li></ul></ul></ul>Inspired by talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
  16. 16. Where’s the beef? <ul><li>Main Classes & APIs: </li></ul><ul><ul><li>Zend_Tool_Framework </li></ul></ul><ul><ul><ul><li>The component responsible for dispatching tooling requests </li></ul></ul></ul><ul><ul><li>Zend_Tool_Project </li></ul></ul><ul><ul><ul><li>The component responsible for exposing the “project specific” tooling capabilities </li></ul></ul></ul><ul><li>And the gravy… </li></ul><ul><li>Supporting Classes & APIs: </li></ul><ul><ul><li>Zend_CodeGenerator </li></ul></ul><ul><ul><li>Zend_Reflection </li></ul></ul>Inspired by talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
  17. 17. Zend_Tool_Framework
  18. 18. Zend_Tool_Framework sub-parts <ul><li>Zend_Tool_Framework </li></ul><ul><ul><li>Dispatch-style framework, designed to abstract enough system internals to make extensibility easy </li></ul></ul><ul><ul><ul><li>“ Flexibility of the tooling dispatch over speed of tooling dispatch” </li></ul></ul></ul><ul><ul><li>Broken down into logical sub-parts: </li></ul></ul><ul><ul><ul><li>Client </li></ul></ul></ul><ul><ul><ul><li>Client storage & configuration </li></ul></ul></ul><ul><ul><ul><li>Loader </li></ul></ul></ul><ul><ul><ul><li>Provider & Provider Repository </li></ul></ul></ul><ul><ul><ul><li>Manifest, Manifest Repository & Metadata </li></ul></ul></ul><ul><ul><ul><li>System (Built-in) Providers </li></ul></ul></ul>From talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
  19. 19. Zend_Tool_Framework sub-parts <ul><li>Zend_Tool_Framework_Client </li></ul><ul><ul><li>Responsibilities: </li></ul></ul><ul><ul><ul><li>Request Object </li></ul></ul></ul><ul><ul><ul><li>Response Object </li></ul></ul></ul><ul><ul><ul><li>Interactivity support </li></ul></ul></ul><ul><ul><ul><li>Setting up the system registry containing all required objects </li></ul></ul></ul><ul><ul><ul><li>The actual dispatch()-ing </li></ul></ul></ul><ul><ul><li>First implementation of Zend_Tool_Framework_Client_Console </li></ul></ul>From talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
  20. 20. Zend_Tool_Framework sub-parts <ul><li>Zend_Tool_Framework_Client_Storage & Zend_Tool_Framework_Client_Config </li></ul><ul><ul><li>Responsibilities: </li></ul></ul><ul><ul><ul><li>Allowing clients to specify configuration values for the system and providers to use </li></ul></ul></ul><ul><ul><ul><li>Allowing clients to store artifacts on the filesystem that the system and providers can consume </li></ul></ul></ul><ul><ul><ul><ul><li>Custom profile files </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Provider-specific file formats and metadata </li></ul></ul></ul></ul>From talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
  21. 21. Zend_Tool_Framework sub-parts <ul><li>Zend_Tool_Framework_Loader </li></ul><ul><ul><li>Responsibilities: </li></ul></ul><ul><ul><ul><li>Load files provided </li></ul></ul></ul><ul><ul><ul><li>Search for classes defined that implement: </li></ul></ul></ul><ul><ul><ul><ul><li>Zend_Tool_Framework_Manifest_Interface </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Zend_Tool_Framework_Provider_Interface </li></ul></ul></ul></ul>From talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
  22. 22. Zend_Tool_Framework sub-parts <ul><li>Zend_Tool_Framework_Provider & Provider Registry </li></ul><ul><ul><li>Responsibilities: </li></ul></ul><ul><ul><ul><li>An interface for defining via a class, dispatch-able actions and “specialties” </li></ul></ul></ul><ul><ul><ul><ul><li>(Similar to how Action Controllers define actions) </li></ul></ul></ul></ul><ul><ul><ul><li>Registry to maintain instances of all providers available </li></ul></ul></ul><ul><ul><ul><li>Parsing of provider classes for dispatch-able “signatures” </li></ul></ul></ul>From talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
  23. 23. Zend_Tool_Framework sub-parts <ul><li>Zend_Tool_Framework_Manifest & Manifest Repository </li></ul><ul><ul><li>Responsibilities: </li></ul></ul><ul><ul><ul><li>Manifest can supply a collection of providers, actions and/or metadata </li></ul></ul></ul><ul><ul><ul><li>Registry provides a way to search for metadata in the manifest </li></ul></ul></ul><ul><li>Zend_Tool_Framework_Metadata </li></ul><ul><ul><li>Responsibilities: </li></ul></ul><ul><ul><ul><li>Primary use case is to attach “data about data” to instance of a specific client, provider, or action </li></ul></ul></ul><ul><ul><ul><ul><li>ex: alternate names for each provider based on the command line naming scheme, OR short names (p for profile) </li></ul></ul></ul></ul>From talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
  24. 24. Zend_Tool_Project
  25. 25. Zend_Tool_Project sub-parts <ul><li>Zend_Tool_Project_Profile </li></ul><ul><ul><li>Responsibilities: </li></ul></ul><ul><ul><ul><li>loading, parsing, serializing and storing a profile file </li></ul></ul></ul><ul><ul><ul><li>Top most node in a “resource tree” </li></ul></ul></ul><ul><li>Zend_Tool_Project_Profile_Resource </li></ul><ul><ul><li>Responsibilities: </li></ul></ul><ul><ul><ul><li>The class most responsible for the “where” question of project modeling </li></ul></ul></ul><ul><ul><ul><li>The class most responsible for implementing a node in a “resource tree” </li></ul></ul></ul><ul><ul><ul><li>Extends Resource_Container which is a RecursiveIterator (tree fundamentals) </li></ul></ul></ul><ul><ul><ul><li>Can create new Resources at specific locations </li></ul></ul></ul><ul><ul><ul><li>Can find resources by name and attribute sets </li></ul></ul></ul><ul><ul><ul><li>Each contains a Zend_Project_Context object </li></ul></ul></ul>From talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
  26. 26. Zend_Tool_Project sub-parts <ul><li>Zend_Tool_Project_Context </li></ul><ul><ul><li>Responsibilities: </li></ul></ul><ul><ul><ul><li>The class most responsible for the “what” part of project modeling </li></ul></ul></ul><ul><ul><ul><li>It is assigned to a Zend_Tool_Project_Profile_Resource object </li></ul></ul></ul><ul><ul><ul><li>Example contexts: </li></ul></ul></ul><ul><ul><ul><ul><li>Controller file </li></ul></ul></ul></ul><ul><ul><ul><ul><li>View script directory </li></ul></ul></ul></ul><ul><ul><ul><ul><li>View script file </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Model file </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Action method </li></ul></ul></ul></ul><ul><ul><ul><ul><li>… </li></ul></ul></ul></ul>From talk by Ralph Schindler of Zend, at ZendCon 2009 http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending
  27. 27. Putting it all together
  28. 28. Putting it all together <ul><li>Zend_Tool_Framework looks for providers, by default, on the include_path </li></ul><ul><ul><li>It recursivly iterates all include path directories and opens all files that end with “Manifest.php” or “Provider.php” </li></ul></ul><ul><ul><li>All classes in these files are inspected if they implement either Zend_Tool_Framework_Provider_Interface or Zend_Tool_Framework_Manifest_ProviderManifestable </li></ul></ul><ul><li>Zend_Tool_Project is consumed by Zend_Tool_Framework </li></ul><ul><ul><li>This allows Zend_Tool_Project to be only concerned with “project” problems </li></ul></ul><ul><ul><li>This also allows Zend_Tool_Framework to focus on the problem of knowing which requests are good, and knowing how to dispatch said request </li></ul></ul><ul><li>Zend_Tool_Framework provides a client to the user </li></ul>
  29. 29. Additional Resources <ul><li>In relation to the information presented in this section </li></ul><ul><li>http://framework.zend.com </li></ul><ul><li>http://framework.zend.com/manual/en </li></ul><ul><li>http://framework.zend.com/manual/1.10/en/zend.tool.html </li></ul><ul><li>http://framework.zend.com/manual/1.10/en/zend.tool.framework.html </li></ul><ul><li>http://framework.zend.com/manual/1.10/en/zend.tool.project.html </li></ul><ul><li>http://framework.zend.com/manual/1.10/en/zend.codegenerator.html </li></ul><ul><li>http://framework.zend.com/manual/1.10/en/zend.reflection.html </li></ul><ul><li>http://www.slideshare.net/ZendCon/zendtool-practical-use-and-extending </li></ul>
  30. 30. Setting things up
  31. 31. Install Zend Framework <ul><li>Download Zend Framework </li></ul><ul><ul><li>From website (http://framework.zend.com) </li></ul></ul><ul><ul><li>SVN </li></ul></ul><ul><ul><li>Zend Server </li></ul></ul><ul><ul><li>From PEAR channel (http://pear.zfcampus.org/) </li></ul></ul><ul><li>Install it </li></ul><ul><ul><li>How? </li></ul></ul><ul><ul><li>Where? </li></ul></ul><ul><ul><ul><li>For purpose of this presentation, have installed it at C:endFramework-1.9.7 </li></ul></ul></ul>
  32. 32. Prepare Zend_Tool
  33. 33. Understanding the CLI Tool <ul><li>/bin/zf.sh and /bin/zf.bat </li></ul><ul><ul><li>Operating system specific client wrappers </li></ul></ul><ul><ul><ul><li>Responsible for finding the proper php.exe, finding the zf.php file, and passing on the client request </li></ul></ul></ul><ul><li>/bin/zf.php </li></ul><ul><ul><li>Responsible for: </li></ul></ul><ul><ul><ul><li>handling the understanding of your environment </li></ul></ul></ul><ul><ul><ul><li>construction of proper include path </li></ul></ul></ul><ul><ul><ul><li>passing what is provided on the command line to the proper library component for dispatching </li></ul></ul></ul>
  34. 34. Accessing the CLI Tool <ul><li>Two things have to be true: </li></ul><ul><ul><li>zf.sh/zf.bat is reachable from your system path. </li></ul></ul><ul><ul><ul><li>This is the ability to call ‘zf’ from anywhere on your command line, regardless of what your current working directory is. </li></ul></ul></ul><ul><ul><li>ZendFramework/library is in your include path </li></ul></ul><ul><li>So how do we === true? </li></ul>
  35. 35. Make zf.sh/zf.bat reachable from system path <ul><li>Manual’s recommendation: </li></ul><ul><ul><li>Copy zf.sh/zf.bat and zf.php into the same directory as your PHP binary </li></ul></ul><ul><ul><ul><li>For *nix, usually: </li></ul></ul></ul><ul><ul><ul><ul><li>/usr/bin/ </li></ul></ul></ul></ul><ul><ul><ul><ul><li>/usr/local/bin/ </li></ul></ul></ul></ul><ul><ul><ul><ul><li>/usr/local/ZendServer/bin/ </li></ul></ul></ul></ul><ul><ul><ul><ul><li>/Applications/ZendServer/bin </li></ul></ul></ul></ul><ul><ul><ul><li>For Windows, usually: </li></ul></ul></ul><ul><ul><ul><ul><li>C:PHP </li></ul></ul></ul></ul><ul><ul><ul><ul><li>C:Program FilesendServerin </li></ul></ul></ul></ul><ul><ul><ul><ul><li>C:WAMPPHPin </li></ul></ul></ul></ul>
  36. 36. Make zf.sh/zf.bat reachable from system path <ul><li>My recommendation: </li></ul><ul><ul><li>Create an Alias to zf.sh/zf.bat </li></ul></ul><ul><ul><ul><li>For *nix: </li></ul></ul></ul><ul><ul><ul><ul><li>alias zf &quot;/usr/local/Zend/ZendFramework-1.9.7/bin/zf.sh&quot; </li></ul></ul></ul></ul><ul><ul><ul><ul><li>alias zf &quot;/YOUR_PATH_HERE/bin/zf.sh&quot; </li></ul></ul></ul></ul><ul><ul><ul><li>For Windows: </li></ul></ul></ul><ul><ul><ul><ul><li>doskey zf=C:ENDFR~1.7inzf.bat </li></ul></ul></ul></ul><ul><ul><li>However…. </li></ul></ul><ul><ul><ul><li>On Windows, I could not get the arguments passed to ‘zf’ to be passed along, so…. </li></ul></ul></ul><ul><ul><ul><li>Ended up modifying the environment variable PATH to include C:endFramework-1.9.7in </li></ul></ul></ul>
  37. 37. Add ZendFramework/library to include_path <ul><li>Manual’s recommendation: </li></ul><ul><ul><li>Determine what your current include_path value is and add the contents of ZendFramework/library to one of these locations </li></ul></ul><ul><ul><li>Alternative option to above: </li></ul></ul><ul><ul><ul><li>For *nix: </li></ul></ul></ul><ul><ul><ul><ul><li>In a location included in your current include_path, create a symbolic link to the location of ZendFramework/library </li></ul></ul></ul></ul><ul><ul><ul><li>For Windows: </li></ul></ul></ul><ul><ul><ul><ul><li>Modify the environment variable PATH to include C:PATH_TO_ZENDFRAMEWORKin </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Alter your php.ini file and modify include_path directive to include C:PATH_TO_ZENDFRAMEWORKlibrary </li></ul></ul></ul></ul>
  38. 38. Add ZendFramework/library to include_path <ul><li>My recommendation: </li></ul><ul><ul><li>Use special environment variable(s) to tell zf.php the location of ZendFramework/library </li></ul></ul><ul><ul><li>They are: </li></ul></ul><ul><ul><ul><li>ZEND_TOOL_INCLUDE_PATH_PREPEND </li></ul></ul></ul><ul><ul><ul><ul><li>Will prepend the value of this environment variable to the system (php.ini) include_path before loading the client </li></ul></ul></ul></ul><ul><ul><ul><li>ZEND_TOOL_INCLUDE_PATH </li></ul></ul></ul><ul><ul><ul><ul><li>Completely replaces the system include_path with the one specified </li></ul></ul></ul></ul><ul><ul><li>How to do this: </li></ul></ul><ul><ul><ul><li>For *nix: </li></ul></ul></ul><ul><ul><ul><ul><li>setenv ZEND_TOOL_INCLUDE_PATH_PREPEND /usr/local/Zend/ZendFramework-1.9.7/library/ </li></ul></ul></ul></ul><ul><ul><ul><li>For Windows: </li></ul></ul></ul><ul><ul><ul><ul><li>set ZEND_TOOL_INCLUDE_PATH_PREPEND=C:ENDFR~1.7library </li></ul></ul></ul></ul>
  39. 39. Other settable environment variables <ul><li>ZF_HOME </li></ul><ul><li>ZF_STORAGE_DIR </li></ul><ul><li>ZF_CONFIG_FILE </li></ul><ul><li>ZF_INCLUDE_PATH </li></ul><ul><li>ZF_INCLUDE_PATH_PREPEND </li></ul><ul><li>Can be found at http://framework.zend.com/manual/en/zend.tool.usage.cli.html </li></ul>
  40. 40. Did I set it up correctly? <ul><li>To verify that the previous steps worked correctly, enter ‘zf’ at the command line. Should expect to see something similar to: </li></ul>
  41. 41. Additional Resources <ul><li>In relation to the information presented in this section </li></ul><ul><li>http://framework.zend.com/manual/1.10/en/zend.tool.framework.html </li></ul><ul><li>http://framework.zend.com/manual/1.10/en/zend.tool.usage.cli.html </li></ul><ul><li>http://framework.zend.com/manual/1.10/en/zend.tool.extending.html </li></ul><ul><li>http://en.wikipedia.org/wiki/Alias_%28command%29 </li></ul><ul><li>http://www.unix.com/windows-dos-issues-discussions/74664-what-dos-equivalent-alias-command.html </li></ul>
  42. 42. Enough with the setup – I’m here for some coding!
  43. 43. Few basic things <ul><li>zf --help </li></ul><ul><li>zf show version </li></ul><ul><li>zf show version </li></ul><ul><li>zf show version -n 0 </li></ul><ul><li>zf show version.major-part </li></ul><ul><li>zf show version -m minor -n 0 </li></ul>
  44. 44. Create project <ul><li>Provide a path: </li></ul><ul><ul><li>zf create project demo </li></ul></ul><ul><li>Be prompted for path: </li></ul><ul><ul><li>zf create project </li></ul></ul>
  45. 45. Create project <ul><li>Provide a path: </li></ul><ul><ul><li>zf create project demo </li></ul></ul><ul><li>Be prompted for path: </li></ul><ul><ul><li>zf create project </li></ul></ul><ul><li>Can now run: </li></ul><ul><ul><li>zf show project </li></ul></ul><ul><ul><li>zf show profile </li></ul></ul>
  46. 46. Create Controller <ul><li>Provide a controller name: </li></ul><ul><ul><li>zf create controller <controllername> </li></ul></ul><ul><li>Be prompted for a controller name: </li></ul><ul><ul><li>zf create controller </li></ul></ul>
  47. 47. Create Controller Actions <ul><li>zf create action <actioname> <controllername> </li></ul><ul><ul><li>Will throw a Fatal Error if <controllername> does not exist </li></ul></ul>
  48. 48. Create views <ul><li>zf create view <controllername> <actionname> </li></ul><ul><ul><li><actionname> is really only for the name of the View Script – a new action is NOT created in the controller </li></ul></ul>
  49. 49. Additional Resources <ul><li>In relation to the information presented in this section </li></ul><ul><li>http://framework.zend.com/manual/en/zend.tool.project.create-a-project.html </li></ul><ul><li>http://framework.zend.com/manual/en/zend.tool.project.providers.html </li></ul><ul><li>http://ralphschindler.com/wiki/index.php/Using_Zend_Tool </li></ul>
  50. 50. Extending Zend_Tool
  51. 51. How Zend_Tool finds your Providers <ul><li>Remember that: </li></ul><ul><li>Zend_Tool_Framework looks for providers, by default, on the include_path </li></ul><ul><ul><li>It recursivly iterates all include path directories and opens all files that end with “Manifest.php” or “Provider.php” </li></ul></ul><ul><ul><li>All classes in these files are inspected if they implement either Zend_Tool_Framework_Provider_Interface or Zend_Tool_Framework_Manifest_ProviderManifestable </li></ul></ul>
  52. 52. How Zend_Tool finds your Providers <ul><li>The following naming rules apply on how you can access the providers that were found by the IncludePathLoader: </li></ul><ul><ul><li>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” </li></ul></ul><ul><ul><li>If your provider has a method getName() it will be used instead of the previous method to determine the name </li></ul></ul><ul><ul><li>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”. </li></ul></ul><ul><li>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. </li></ul>
  53. 53. Example Custom Provider
  54. 54. Minimum code needed… /My/Provider/Slide54Provider.php
  55. 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. 56. Provide alternate name for Provider /My/Provider/Slide56Provider.php
  57. 57. Example Custom Manifest
  58. 58. Minimum code needed /My/Manifest/Slide58Manifest.php
  59. 59. Let’s do more with Providers
  60. 60. Passing variables to a Provider /My/Provider/Slide60.php <ul><li>Examples of how to call this provider: </li></ul><ul><ul><li>zf say slide60 </li></ul></ul><ul><ul><li>zf say slide60 Jason </li></ul></ul><ul><ul><li>zf say slide60 --name Jason </li></ul></ul>
  61. 61. Prompt user for input /My/Provider/Slide61.php
  62. 62. Pretendability /My/Provider/Slide62.php <ul><li>Examples of how to call this provider: </li></ul><ul><ul><li>zf say slide62 </li></ul></ul><ul><ul><li>zf --pretend say slide62 </li></ul></ul>
  63. 63. Verbose /My/Provider/Slide63.php <ul><li>Examples of how to call this provider: </li></ul><ul><ul><li>zf say slide63 </li></ul></ul><ul><ul><li>zf --verbose say slide63 </li></ul></ul>
  64. 64. Debug /My/Provider/Slide64.php <ul><li>Examples of how to call this provider: </li></ul><ul><ul><li>zf say slide64 </li></ul></ul><ul><ul><li>zf --debug say slide64 </li></ul></ul>
  65. 65. Multiple arguments /My/Provider/Slide65.php
  66. 66. Additional Resources <ul><li>In relation to the information presented in this section </li></ul><ul><li>http://framework.zend.com/manual/en/zend.tool.extending.html </li></ul><ul><li>http://framework.zend.com/manual/en/zend.tool.framework.writing-providers.html </li></ul>
  67. 67. Customizing Zend_Tool Console Client
  68. 68. Customizing Zend_Tool Console Client <ul><li>Zend_Tool_Framework allows developers to store information, provider-specific configuration values, and custom files in a special location on the developers machine. </li></ul><ul><li>Items of discussion: </li></ul><ul><ul><li>Home Directory </li></ul></ul><ul><ul><li>Local Storage </li></ul></ul><ul><ul><li>User Configuration </li></ul></ul>
  69. 69. Additional Resources <ul><li>In relation to the information presented in this section </li></ul><ul><li>http://framework.zend.com/manual/1.10/en/zend.tool.framework.extending.html </li></ul><ul><li>http://framework.zend.com/manual/en/zend.tool.framework.writing-providers.html </li></ul>
  70. 70. Putting our Providers to work
  71. 71. Keep profile up-to-date $this->_loadProfile(); $this->_storeProfile();
  72. 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. 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. 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. 75. Additional Resources <ul><li>In relation to the information presented in this section </li></ul><ul><li>http://framework.zend.com/manual/en/zend.tool.extending.html </li></ul><ul><li>http://www.zend.com/en/webinar/framework/webinar-zend-tool-20090630.flv </li></ul>
  76. 76. Where do things go from here?
  77. 77. Known plans
  78. 78. Roadmap <ul><li>Zend Framework 1.10 offers </li></ul><ul><ul><li>Model Provider </li></ul></ul><ul><ul><li>Form Provider </li></ul></ul><ul><ul><li>DbTable Provider </li></ul></ul><ul><ul><li>DbAdapter configuration </li></ul></ul><ul><ul><li>Layout enabling and creation </li></ul></ul><ul><ul><li>Custom Profiles </li></ul></ul><ul><ul><li>Improved Module Provider </li></ul></ul><ul><ul><li>… and more! </li></ul></ul><ul><li>In the works </li></ul><ul><ul><li>Web interface </li></ul></ul><ul><ul><li>Better documentation </li></ul></ul><ul><li>Have hopes for </li></ul><ul><ul><li>Apache configuration code generator </li></ul></ul>
  79. 79. Using for your own needs
  80. 80. The sky’s the limit <ul><li>Don’t have to use it for just a “project” </li></ul><ul><li>How Spear One has begun, and plans, on using Zend_Tool </li></ul>
  81. 81. Improving Zend_Tool
  82. 82. Public Service Announcement <ul><li>Play with it and use it </li></ul><ul><li>Submit bugs and feature requests </li></ul><ul><ul><li>http://framework.zend.com/issues/browse/ZF/component/10380 </li></ul></ul><ul><li>Get involved in the community </li></ul><ul><ul><li>Write a blog post </li></ul></ul><ul><ul><li>Visit #zftalk on irc.freenode.net </li></ul></ul><ul><ul><li>Become a contributor </li></ul></ul><ul><ul><ul><li>Fix bugs </li></ul></ul></ul><ul><ul><ul><li>Implement new feature set </li></ul></ul></ul><ul><ul><ul><li>Improve documentation </li></ul></ul></ul>
  83. 83. Additional Resources <ul><li>In relation to the information presented in this section </li></ul><ul><li>http://framework.zend.com/issues/browse/ZF/component/10380 </li></ul><ul><li>http://framework.zend.com/issues/browse/ZF-7940 </li></ul><ul><li>http://ralphschindler.com/wiki/index.php/Using_Zend_Tool </li></ul>
  84. 84. Thank you!
  85. 85. Contact Information <ul><li>Blog: notmessenger.com </li></ul><ul><li>Twitter: twitter.com/notmessenger </li></ul><ul><li>Email: jeremy@notmessenger.com </li></ul><ul><li>IRC: #zftalk and #dallasphp </li></ul><ul><li>Where to find presentation </li></ul><ul><ul><li>notmessenger.com/presentations </li></ul></ul><ul><ul><li><insert slideshare.net link here> </li></ul></ul><ul><li>Please rate this talk on Joind.in </li></ul><ul><ul><li>http://joind.in/event/view/136 </li></ul></ul>

×