Zend_Tool_Framework-CliTool.xml 12 KB

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