Zend_Tool_Framework-CliTool.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- EN-Revision: 16656 -->
  3. <!-- Reviewed: no -->
  4. <sect1 id="zend.tool.framework.clitool">
  5. <title>Usando la herramienta CLI</title>
  6. <para>
  7. The <acronym>CLI</acronym>, or command line tool (internally known as the console tool),
  8. is currently the primary interface for dispatching <classname>Zend_Tool</classname>
  9. requests. With the <acronym>CLI</acronym> tool, developers can issue tooling requests
  10. inside 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. <filename>cmd.exe</filename>, 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 set up the client so that your system can handle the "zf"
  20. command. The command line client, for all intents and purposes, is
  21. the <filename>.sh</filename> or <filename>.bat</filename> file that is provided with
  22. your Zend Framework distribution. In trunk, it can be found here:
  23. <ulink
  24. url="http://framework.zend.com/svn/framework/standard/trunk/bin/">http://framework.zend.com/svn/framework/standard/trunk/bin/</ulink>.
  25. </para>
  26. <para>
  27. As you can see, there are 3 files in the <filename>/bin/</filename>
  28. directory: a <filename>zf.php</filename>, <filename>zf.sh</filename>, and
  29. <filename>zf.bat</filename>. The <filename>zf.sh</filename> and the
  30. <filename>zf.bat</filename> are the operating system specific client
  31. wrappers: <filename>zf.sh</filename> for the *nix environment, and
  32. <filename>zf.bat</filename> for the Win32 environment. These client wrappers are
  33. responsible for finding the proper <filename>php.exe</filename>, finding the
  34. <filename>zf.php</filename>, and passing on the client request. The
  35. <filename>zf.php</filename> is the responsible for handling understanding
  36. your environment, constructing the proper include_path, and passing
  37. what is provided on the command line to the proper library component
  38. for dispatching.
  39. </para>
  40. <para>
  41. Ultimately, you want to ensure two things to make everything work
  42. regardless of the operating system you are on:
  43. </para>
  44. <orderedlist>
  45. <listitem>
  46. <para>
  47. <filename>zf.sh/zf.bat</filename> is reachable from your system
  48. path. This is the ability to call <command>zf</command> from
  49. anywhere on your command line, regardless of what your
  50. current working directory is.
  51. </para>
  52. </listitem>
  53. <listitem>
  54. <para>
  55. <filename>ZendFramework/library</filename> is in your
  56. <property>include_path</property>.
  57. </para>
  58. </listitem>
  59. </orderedlist>
  60. <note>
  61. <para>
  62. Note: while the above are the most ideal
  63. requirements, you can simply download Zend Framework and expect it
  64. to work as <filename>./path/to/zf.php</filename> some command.
  65. </para>
  66. </note>
  67. </sect2>
  68. <sect2 id="zend.tool.framework.clitool.setup-starnix">
  69. <title>Setting up the CLI tool on Unix-like Systems</title>
  70. <para>
  71. The most common setup in the *nix environment, is to copy the
  72. <filename>zf.sh</filename> and <filename>zf.php</filename> into the same directory
  73. as your <acronym>PHP</acronym> binary. This can generally be found in one of the
  74. following places:
  75. </para>
  76. <programlisting language="text"><![CDATA[
  77. /usr/bin
  78. /usr/local/bin
  79. /usr/local/ZendServer/bin/
  80. /Applications/ZendServer/bin/
  81. ]]></programlisting>
  82. <para>
  83. To find out the location of your <acronym>PHP</acronym> binary, you can execute 'which
  84. php' on the command line. This will return the location of the <acronym>PHP</acronym>
  85. binary you will be using to run <acronym>PHP</acronym> scripts in this environment.
  86. </para>
  87. <para>
  88. The next order of business is to ensure that Zend Framework
  89. library is set up correctly inside of the system <acronym>PHP</acronym>
  90. <property>include_path</property>. To find out where your
  91. <property>include_path</property> is located, you can execute <command>php -i</command>
  92. and look for the <property>include_path</property> variable, or more succinctly,
  93. execute <command>php -i | grep include_path</command>. Once you have found where
  94. your <property>include_path</property> is located (this will generally be
  95. something like <filename>/usr/lib/php</filename>, <filename>/usr/share/php</filename>,
  96. <filename>/usr/local/lib/php</filename>, or similar), ensure that the contents of the
  97. <filename>/library/</filename> directory are put
  98. inside your <property>include_path</property> specified directory.
  99. </para>
  100. <para>
  101. Once you have done those two things, you should be able to issue a
  102. command and get back the proper response like this:
  103. </para>
  104. <para>
  105. <inlinegraphic scale="100" align="center" valign="middle"
  106. fileref="figures/zend.tool.framework.cliversionunix.png" format="PNG" />
  107. </para>
  108. <para>
  109. If you do not see this type of output, go back and check your setup
  110. to ensure you have all of the necessary pieces in the proper place.
  111. </para>
  112. <para>
  113. There are a couple of alternative setups you might want to employ
  114. depending on your servers configuration, your level of access, or
  115. for other reasons.
  116. </para>
  117. <para>
  118. <emphasis>Alternative Setup</emphasis> involves keeping the Zend
  119. Framework download together as is, and creating a link from a <constant>PATH</constant>
  120. location to the <filename>zf.sh</filename>. What this means is you can
  121. place the contents of the ZendFramework download into a location
  122. such as <filename>/usr/local/share/ZendFramework</filename>, or more locally
  123. like <filename>/home/username/lib/ZendFramework</filename>, and creating a
  124. symbolic link to the <filename>zf.sh</filename>.
  125. </para>
  126. <para>
  127. Assuming you want to put the link inside <filename>/usr/local/bin</filename>
  128. (this could also work for placing the link inside
  129. <filename>/home/username/bin/</filename> for example) you would issue a
  130. command similar to this:</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>