Skip to end of metadata
Go to start of metadata

<ac:macro ac:name="note"><ac:parameter ac:name="title">Under Construction</ac:parameter><ac:rich-text-body>
<p>This proposal is under construction and is not ready for review.</p></ac:rich-text-body></ac:macro>

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[

Zend Framework: Zend_Controller_Request_Cli Component Proposal

Proposed Component Name Zend_Controller_Request_Cli
Developer Notes http://framework.zend.com/wiki/display/ZFDEV/Zend_Controller_Request_Cli
Proposers Matthew Weier O'Phinney
Revision 0.9 - 2 February 2007: Initial proposal (wiki revision: 3)

Table of Contents

1. Overview

Zend_Controller_Request_Cli will integrate with Zend_Console_Getopt to provide a CLI request object for use with the MVC components. It will allow passing controller and action options to a CLI script, as well as any number of additional options.

2. References

3. Component Requirements, Constraints, and Acceptance Criteria

  • This component will allow specifying the option keys for the controller and action, but fall back to sane defaults
  • This component will allow specifying any number of additional CLI options and capture them in the request

4. Dependencies on Other Framework Components

  • Zend_Console_Getopt
  • Zend_Controller_Request_Abstract
  • Zend_Controller_Request_Exception

5. Theory of Operation

The component is initialized with a null constructor, and then passed to the front controller via either setRequest() or as the first argument to dispatch().

6. Milestones / Tasks

  • Milestone 1: Finish proposal with sample code
  • Milestone 2: Working prototype checked into the incubator
  • Milestone 3: Unit tests exist, work, and are checked into SVN.
  • Milestone 4: Initial documentation exists.
  • Milestone 5: Promotion to core.

7. Class Index

  • Zend_Controller_Request_Cli

8. Use Cases

UC-01
UC-02
UC-03

9. Class Skeletons

]]></ac:plain-text-body></ac:macro>

]]></ac:plain-text-body></ac:macro>

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Feb 05, 2007

    <p>When do you think you'll have this available for testing?</p>

  2. Feb 05, 2007

    <p>Should be named <code>Zend_Controller_Request_Console</code> to be in line with <code>Zend_Console_Getopt</code>. As Bill puts it, to avoid needless three-letter acronyms when a word will suffice.</p>

    <p>I'm glad you're doing this; I need something like it. I was thinking along these lines, but I didn't have the time to do another proposal (I don't have enough time to deal with my proposals as it is!).</p>

    <p>Shouldn't this be dependent on <code>Zend_Controller_Response_Console</code> (currently <code>Cli</code>)?</p>

  3. Feb 20, 2007

    <p>I was thinking more about this. It seems like there's room for two types of console request classes.</p>

    <p>One is sort of what you've outlined here, where requests are something like this:</p>

    <p><code>php index.php --controller=index --action=index --param1=value --param2=value</code></p>

    <p>This requires a corresponding <code>Zend_Controller_Router_Console</code> class, and as far as I know isn't possible yet (in this form, at least) because <code>Zend_Console_Getopt</code> doesn't support dynamic values (param1, param2, etc.).</p>

    <p>The second mimics the URL request type:</p>

    <p><code>php index.php /some/request/param1/value/param2/value</code></p>

    <p>Maybe it could be called <code>Zend_Controller_Request_HttpConsole</code> or something. Anyway, this seems more convenient for certain tasks. No special router is required, so the main obstacle is the requirement in <code>Zend_Controller_Router_Rewrite</code> for a <code>Zend_Controller_Request_Http</code> class. I quickly mocked up something like this, which (for the purposes of a quick prototype) extended <code>Http</code> instead of <code>Abstract</code>. It worked great.</p>

    <p>In my revised <code>Zend_Scheduler</code> design I've reworked it to use a pseudo-daemon (in PHP) so that it acts exactly like Crontab (and would genuinely be useful). But for it to work it needs the ability to make requests via the command line, so this class is of special interest to me. Let me know if you need help to finish it.</p>

    1. Feb 20, 2007

      <p>I definitely like the second way of doing the request: </p>

      <p>php index.php /some/request/param1/value/param2/value</p>

      <p>This would follow the same scheme as the browser http request. Also, the first method you described </p>

      <p>php index.php --controller=index --action=index --param1=value --param2=value</p>

      <p>seems to be particular to a Unix/Linux command rather than a universal Win/*nix non-biased scheme.</p>

  4. Dec 25, 2007

    <p>I think there is no "One True Way" for console input parsing. What about supporting multiple ways to retrieve parameters, or providing a (more feature-rich than getopt) DSL for the way parameters can be specified?</p>

    <p>php index.php --option=value -flag verb subject object <ac:link><ri:page ri:content-title="set,of,params" /></ac:link><br />
    php index.php method param1 param2 param3 --option=value --option2=value<br />
    php index.php /tradional/url/with?get=params&flags=&moreflags=<br />
    ...</p>

  5. Oct 24, 2009

    <p>Is this job continued to be released? I cant find not way to run Cron jobs with ZF</p>

    1. Oct 25, 2009

      <p>You could try this: <a class="external-link" href="http://blog.astrumfutura.com/archives/418-The-Mysteries-Of-Asynchronous-Processing-With-PHP-Part-2-Making-Zend-Framework-Applications-CLI-Accessible.html">http://blog.astrumfutura.com/archives/418-The-Mysteries-Of-Asynchronous-Processing-With-PHP-Part-2-Making-Zend-Framework-Applications-CLI-Accessible.html</a></p>