Zend_Tool_Framework-CliTool.xml 12 KB

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