• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Using Zend_Tool to Establish Your Project's Skeleton
 

Using Zend_Tool to Establish Your Project's Skeleton

on

  • 4,708 views

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

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/

Statistics

Views

Total Views
4,708
Views on SlideShare
4,640
Embed Views
68

Actions

Likes
9
Downloads
0
Comments
0

5 Embeds 68

http://www.notmessenger.com 28
http://www.scoop.it 20
http://www.slideshare.net 17
http://www.linkedin.com 2
https://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Using Zend_Tool to Establish Your Project's Skeleton Using Zend_Tool to Establish Your Project's Skeleton Presentation Transcript

    • 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:endFramework-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 FilesendServerin
            • C:WAMPPHPin
    • 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:ENDFR~1.7inzf.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:endFramework-1.9.7in
    • 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_ZENDFRAMEWORKin
            • Alter your php.ini file and modify include_path directive to include C:PATH_TO_ZENDFRAMEWORKlibrary
    • 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:ENDFR~1.7library
    • 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