Zend_Tool_Framework-CliTool.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.tool.framework.clitool">
  4. <title>Using the CLI Tool</title>
  5. <para>
  6. The <acronym>CLI</acronym>, or command line tool (internally known as the console tool),
  7. is currently the primary interface for dispatching <classname>Zend_Tool</classname>
  8. requests. With the <acronym>CLI</acronym> tool, developers can issue tooling requests
  9. inside the "command line windows", also commonly known as a "terminal"
  10. window. This environment is predominant in the *nix environment, but
  11. also has a common implementation in windows with the
  12. <filename>cmd.exe</filename>, console2 and also with the Cygwin project.
  13. </para>
  14. <sect2 id="zend.tool.framework.clitool.setup-general">
  15. <title>Setting up the CLI tool</title>
  16. <para>
  17. To issue tooling requests via the command line client, you first
  18. need to set up the client so that your system can handle the "zf"
  19. command. The command line client, for all intents and purposes, is
  20. the <filename>.sh</filename> or <filename>.bat</filename> file that is provided with
  21. your Zend Framework distribution. In trunk, it can be found here:
  22. <ulink
  23. url="http://framework.zend.com/svn/framework/standard/trunk/bin/">http://framework.zend.com/svn/framework/standard/trunk/bin/</ulink>.
  24. </para>
  25. <para>
  26. As you can see, there are 3 files in the <filename>/bin/</filename>
  27. directory: a <filename>zf.php</filename>, <filename>zf.sh</filename>, and
  28. <filename>zf.bat</filename>. The <filename>zf.sh</filename> and the
  29. <filename>zf.bat</filename> are the operating system specific client
  30. wrappers: <filename>zf.sh</filename> for the *nix environment, and
  31. <filename>zf.bat</filename> for the Win32 environment. These client wrappers are
  32. responsible for finding the proper <filename>php.exe</filename>, finding the
  33. <filename>zf.php</filename>, and passing on the client request. The
  34. <filename>zf.php</filename> is the responsible for handling understanding
  35. your environment, constructing the proper include_path, and passing
  36. what is provided on the command line to the proper library component
  37. for dispatching.
  38. </para>
  39. <para>
  40. Ultimately, you want to ensure two things to make everything work
  41. regardless of the operating system you are on:
  42. </para>
  43. <orderedlist>
  44. <listitem>
  45. <para>
  46. <filename>zf.sh/zf.bat</filename> is reachable from your system
  47. path. This is the ability to call <command>zf</command> from
  48. anywhere on your command line, regardless of what your
  49. current working directory is.
  50. </para>
  51. </listitem>
  52. <listitem>
  53. <para>
  54. <filename>ZendFramework/library</filename> is in your
  55. <property>include_path</property>.
  56. </para>
  57. </listitem>
  58. </orderedlist>
  59. <note>
  60. <para>
  61. Note: while the above are the most ideal
  62. requirements, you can simply download Zend Framework and expect it
  63. to work as <filename>./path/to/zf.php</filename> some command.
  64. </para>
  65. </note>
  66. </sect2>
  67. <sect2 id="zend.tool.framework.clitool.setup-starnix">
  68. <title>Setting up the CLI tool on Unix-like Systems</title>
  69. <para>
  70. The most common setup in the *nix environment, is to copy the
  71. <filename>zf.sh</filename> and <filename>zf.php</filename> into the same directory
  72. as your <acronym>PHP</acronym> binary. This can generally be found in one of the
  73. following places:
  74. </para>
  75. <programlisting language="text"><![CDATA[
  76. /usr/bin
  77. /usr/local/bin
  78. /usr/local/ZendServer/bin/
  79. /Applications/ZendServer/bin/
  80. ]]></programlisting>
  81. <para>
  82. To find out the location of your <acronym>PHP</acronym> binary, you can execute 'which
  83. php' on the command line. This will return the location of the <acronym>PHP</acronym>
  84. binary you will be using to run <acronym>PHP</acronym> scripts in this environment.
  85. </para>
  86. <para>
  87. The next order of business is to ensure that Zend Framework
  88. library is set up correctly inside of the system <acronym>PHP</acronym>
  89. <property>include_path</property>. To find out where your
  90. <property>include_path</property> is located, you can execute <command>php -i</command>
  91. and look for the <property>include_path</property> variable, or more succinctly,
  92. execute <command>php -i | grep include_path</command>. Once you have found where
  93. your <property>include_path</property> is located (this will generally be
  94. something like <filename>/usr/lib/php</filename>, <filename>/usr/share/php</filename>,
  95. <filename>/usr/local/lib/php</filename>, or similar), ensure that the contents of the
  96. <filename>/library/</filename> directory are put
  97. inside your <property>include_path</property> specified directory.
  98. </para>
  99. <para>
  100. Once you have done those two things, you should be able to issue a
  101. command and get back the proper response like this:
  102. </para>
  103. <para>
  104. <inlinegraphic scale="100" align="center" valign="middle"
  105. fileref="figures/zend.tool.framework.cliversionunix.png" format="PNG" />
  106. </para>
  107. <para>
  108. If you do not see this type of output, go back and check your setup
  109. to ensure you have all of the necessary pieces in the proper place.
  110. </para>
  111. <para>
  112. There are a couple of alternative setups you might want to employ
  113. depending on your servers configuration, your level of access, or
  114. for other reasons.
  115. </para>
  116. <para>
  117. <emphasis>Alternative Setup</emphasis> involves keeping the Zend
  118. Framework download together as is, and creating a link from a <constant>PATH</constant>
  119. location to the <filename>zf.sh</filename>. What this means is you can
  120. place the contents of the ZendFramework download into a location
  121. such as <filename>/usr/local/share/ZendFramework</filename>, or more locally
  122. like <filename>/home/username/lib/ZendFramework</filename>, and creating a
  123. symbolic link to the <filename>zf.sh</filename>.
  124. </para>
  125. <para>
  126. Assuming you want to put the link inside <filename>/usr/local/bin</filename>
  127. (this could also work for placing the link inside
  128. <filename>/home/username/bin/</filename> for example) you would issue a
  129. command similar to this:
  130. </para>
  131. <programlisting language="sh"><![CDATA[
  132. ln -s /usr/local/share/ZendFramework/bin/zf.sh /usr/local/bin/zf
  133. # OR (for example)
  134. ln -s /home/username/lib/ZendFramework/bin/zf.sh /home/username/bin/zf
  135. ]]></programlisting>
  136. <para>
  137. This will create a link which you should be able to access globally
  138. on the command line.
  139. </para>
  140. </sect2>
  141. <sect2 id="zend.tool.framework.clitool.setup-windows">
  142. <title>Setting up the CLI tool on Windows</title>
  143. <para>
  144. The most common setup in the Windows Win32 environment, is to copy
  145. the <filename>zf.bat</filename> and <filename>zf.php</filename> into the same
  146. directory as your <acronym>PHP</acronym> binary. This can generally be found in one of
  147. the following places:
  148. </para>
  149. <programlisting language="text"><![CDATA[
  150. C:\PHP
  151. C:\Program Files\ZendServer\bin\
  152. C:\WAMP\PHP\bin
  153. ]]></programlisting>
  154. <para>
  155. You should be able to run <filename>php.exe</filename> on the command line.
  156. If you are not able to, first check the documentation that came with
  157. your <acronym>PHP</acronym> distribution, or ensure that the path to
  158. <filename>php.exe</filename> is in your
  159. Windows <constant>PATH</constant> environment variable.
  160. </para>
  161. <para>
  162. The next order of business is to ensure that Zend Framework
  163. library is set up correctly inside of the system <acronym>PHP</acronym>
  164. <property>include_path</property>. To find out where your
  165. <property>include_path</property> is located, you can type <command>php -i</command> and
  166. look for the <property>include_path</property> variable, or more succinctly
  167. execute <command>php -i | grep include_path</command> if you have Cygwin setup with
  168. grep available. Once you have found where your
  169. <property>include_path</property> is located (this will generally be
  170. something like <filename>C:\PHP\pear</filename>, <filename>C:\PHP\share</filename>,
  171. <filename>C:\Program%20Files\ZendServer\share</filename> or similar), ensure
  172. that the contents of the library/ directory are put inside your
  173. <property>include_path</property> specified directory.
  174. </para>
  175. <para>
  176. Once you have done those two things, you should be able to issue a
  177. command and get back the proper response like this:
  178. </para>
  179. <para>
  180. <inlinegraphic scale="100" align="center" valign="middle"
  181. fileref="figures/zend.tool.framework.cliversionwin32.png" format="PNG" />
  182. </para>
  183. <para>
  184. If you do not see this type of output, go back and check your setup
  185. to ensure you have all of the necessary pieces in the proper place.
  186. </para>
  187. <para>
  188. There are a couple of alternative setups you might want to employ
  189. depending on your server's configuration, your level of access, or
  190. for other reasons.
  191. </para>
  192. <para>
  193. <emphasis>Alternative Setup</emphasis> involves keeping the Zend
  194. Framework download together as is, and altering both your system
  195. <constant>PATH</constant> as well as the <filename>php.ini</filename> file.
  196. In your user's environment, make sure to add
  197. <filename>C:\Path\To\ZendFramework\bin</filename>, so that your
  198. <filename>zf.bat</filename> file is executable. Also, alter the
  199. <filename>php.ini</filename> file to ensure that
  200. <filename>C:\Path\To\ZendFramework\library</filename> is in your
  201. <property>include_path</property>.
  202. </para>
  203. </sect2>
  204. <sect2 id="zend.tool.framework.clitool.setup-othernotes">
  205. <title>Other Setup Considerations</title>
  206. <para>
  207. If for some reason you do not want Zend Framework library inside
  208. your <property>include_path</property>, there is another option. There are
  209. two special environment variables that <filename>zf.php</filename> will
  210. utilize to determine the location of your Zend Framework
  211. installation.
  212. </para>
  213. <para>
  214. The first is <constant>ZEND_TOOL_INCLUDE_PATH_PREPEND</constant>, which will
  215. prepend the value of this environment variable to the system
  216. (<filename>php.ini</filename>) <property>include_path</property> before loading the
  217. client.
  218. </para>
  219. <para>
  220. Alternatively, you might want to use
  221. <constant>ZEND_TOOL_INCLUDE_PATH</constant> to completely
  222. <emphasis>replace</emphasis> the system <property>include_path</property>
  223. for one that makes sense specifically for the <command>zf</command>
  224. command line tool.
  225. </para>
  226. </sect2>
  227. <sect2 id="zend.tool.framework.clitool.continuing">
  228. <title>Where To Go Next?</title>
  229. <para>
  230. At this point, you should be set up to start initiating some more
  231. "interesting" commands. To get going, you can issue the
  232. <command>zf --help</command> command to see what is available to you.
  233. </para>
  234. <para>
  235. <inlinegraphic scale="100" align="center" valign="middle"
  236. fileref="figures/zend.tool.framework.clihelp.png" format="PNG" />
  237. </para>
  238. <para>
  239. Continue on to the <classname>Zend_Tool_Project</classname> "Create Project"
  240. section to understand how to use the <command>zf</command> script for
  241. project creation.
  242. </para>
  243. </sect2>
  244. </sect1>