Zend_Tool_Framework-CliTool.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  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
  8. <acronym>CLI</acronym>
  9. , or command line tool (internally known as the console tool),
  10. is currently the primary
  11. interface for dispatching
  12. <classname>Zend_Tool</classname>
  13. requests. With the
  14. <acronym>CLI</acronym>
  15. tool, developers can issue tooling requests
  16. inside the "command line windows", also commonly
  17. known as a "terminal"
  18. window. This environment is predominant in the *nix environment, but
  19. also has a common implementation in windows with the
  20. <filename>cmd.exe</filename>
  21. , console2 and also with the Cygwin project.
  22. </para>
  23. <sect2 id="zend.tool.framework.clitool.setup-general">
  24. <title>Setting up the CLI tool</title>
  25. <para>
  26. To issue tooling requests via the command line client, you first
  27. need to set up the
  28. client so that your system can handle the "zf"
  29. command. The command line client, for all
  30. intents and purposes, is
  31. the
  32. <filename>.sh</filename>
  33. or
  34. <filename>.bat</filename>
  35. file that is provided with
  36. your Zend Framework distribution. In trunk, it can be found
  37. here:
  38. <ulink url="http://framework.zend.com/svn/framework/standard/trunk/bin/">
  39. http://framework.zend.com/svn/framework/standard/trunk/bin/
  40. </ulink>
  41. .
  42. </para>
  43. <para>
  44. As you can see, there are 3 files in the
  45. <filename>/bin/</filename>
  46. directory: a
  47. <filename>zf.php</filename>
  48. ,
  49. <filename>zf.sh</filename>
  50. , and
  51. <filename>zf.bat</filename>
  52. . The
  53. <filename>zf.sh</filename>
  54. and the
  55. <filename>zf.bat</filename>
  56. are the operating system specific client
  57. wrappers:
  58. <filename>zf.sh</filename>
  59. for the *nix environment, and
  60. <filename>zf.bat</filename>
  61. for the Win32 environment. These client wrappers are
  62. responsible for finding the proper
  63. <filename>php.exe</filename>
  64. , finding the
  65. <filename>zf.php</filename>
  66. , and passing on the client request. The
  67. <filename>zf.php</filename>
  68. is the responsible for handling understanding
  69. your environment, constructing the proper
  70. include_path, and passing
  71. what is provided on the command line to the proper library
  72. component
  73. for dispatching.
  74. </para>
  75. <para>
  76. Ultimately, you want to ensure two things to make everything work
  77. regardless of the
  78. operating system you are on:
  79. </para>
  80. <orderedlist>
  81. <listitem>
  82. <para>
  83. <filename>zf.sh/zf.bat</filename>
  84. is reachable from your system
  85. path. This is the ability to call
  86. <command>zf</command>
  87. from
  88. anywhere on your command line, regardless of what your
  89. current working
  90. directory is.
  91. </para>
  92. </listitem>
  93. <listitem>
  94. <para>
  95. <filename>ZendFramework/library</filename>
  96. is in your
  97. <property>include_path</property>
  98. .
  99. </para>
  100. </listitem>
  101. </orderedlist>
  102. <note>
  103. <para>
  104. Note: while the above are the most ideal
  105. requirements, you can simply download Zend
  106. Framework and expect it
  107. to work as
  108. <filename>./path/to/zf.php</filename>
  109. some command.
  110. </para>
  111. </note>
  112. </sect2>
  113. <sect2 id="zend.tool.framework.clitool.setup-starnix">
  114. <title>Setting up the CLI tool on Unix-like Systems</title>
  115. <para>
  116. The most common setup in the *nix environment, is to copy the
  117. <filename>zf.sh</filename>
  118. and
  119. <filename>zf.php</filename>
  120. into the same directory
  121. as your
  122. <acronym>PHP</acronym>
  123. binary. This can generally be found in one of the
  124. following places:
  125. </para>
  126. <programlisting language="text"><![CDATA[
  127. /usr/bin
  128. /usr/local/bin
  129. /usr/local/ZendServer/bin/
  130. /Applications/ZendServer/bin/
  131. ]]></programlisting>
  132. <para>
  133. To find out the location of your
  134. <acronym>PHP</acronym>
  135. binary, you can execute 'which
  136. php' on the command line. This will return the location of
  137. the
  138. <acronym>PHP</acronym>
  139. binary you will be using to run
  140. <acronym>PHP</acronym>
  141. scripts in this environment.
  142. </para>
  143. <para>
  144. The next order of business is to ensure that Zend Framework
  145. library is set up correctly
  146. inside of the system
  147. <acronym>PHP</acronym>
  148. <property>include_path</property>
  149. . To find out where your
  150. <property>include_path</property>
  151. is located, you can execute
  152. <command>php -i</command>
  153. and look for the
  154. <property>include_path</property>
  155. variable, or more succinctly,
  156. execute
  157. <command>php -i | grep include_path</command>
  158. . Once you have found where
  159. your
  160. <property>include_path</property>
  161. is located (this will generally be
  162. something like
  163. <filename>/usr/lib/php</filename>
  164. ,
  165. <filename>/usr/share/php</filename>
  166. ,
  167. <filename>/usr/local/lib/php</filename>
  168. , or similar), ensure that the contents of the
  169. <filename>/library/</filename>
  170. directory are put
  171. inside your
  172. <property>include_path</property>
  173. 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
  178. the proper response like this:
  179. </para>
  180. <para>
  181. <inlinegraphic scale="100" align="center" valign="middle"
  182. fileref="figures/zend.tool.framework.cliversionunix.png" format="PNG"/>
  183. </para>
  184. <para>
  185. If you do not see this type of output, go back and check your setup
  186. to ensure you have
  187. all of the necessary pieces in the proper place.
  188. </para>
  189. <para>
  190. There are a couple of alternative setups you might want to employ
  191. depending on your
  192. servers configuration, your level of access, or
  193. for other reasons.
  194. </para>
  195. <para>
  196. <emphasis>Alternative Setup</emphasis>
  197. involves keeping the Zend
  198. Framework download together as is, and creating a link from a
  199. <constant>PATH</constant>
  200. location to the
  201. <filename>zf.sh</filename>
  202. . What this means is you can
  203. place the contents of the ZendFramework download into a
  204. location
  205. such as
  206. <filename>/usr/local/share/ZendFramework</filename>
  207. , or more locally
  208. like
  209. <filename>/home/username/lib/ZendFramework</filename>
  210. , and creating a
  211. symbolic link to the
  212. <filename>zf.sh</filename>
  213. .
  214. </para>
  215. <para>
  216. Assuming you want to put the link inside
  217. <filename>/usr/local/bin</filename>
  218. (this could also work for placing the link inside
  219. <filename>/home/username/bin/</filename>
  220. for example) you would issue a
  221. command similar to this:
  222. </para>
  223. <programlisting language="sh"><![CDATA[
  224. ln -s /usr/local/share/ZendFramework/bin/zf.sh /usr/local/bin/zf
  225. # OR (for example)
  226. ln -s /home/username/lib/ZendFramework/bin/zf.sh /home/username/bin/zf
  227. ]]></programlisting>
  228. <para>
  229. This will create a link which you should be able to access globally
  230. on the command
  231. line.
  232. </para>
  233. </sect2>
  234. <sect2 id="zend.tool.framework.clitool.setup-windows">
  235. <title>Setting up the CLI tool on Windows</title>
  236. <para>
  237. The most common setup in the Windows Win32 environment, is to copy
  238. the
  239. <filename>zf.bat</filename>
  240. and
  241. <filename>zf.php</filename>
  242. into the same
  243. directory as your
  244. <acronym>PHP</acronym>
  245. binary. This can generally be found in one of
  246. the following places:
  247. </para>
  248. <programlisting language="text"><![CDATA[
  249. C:\PHP
  250. C:\Program Files\ZendServer\bin\
  251. C:\WAMP\PHP\bin
  252. ]]></programlisting>
  253. <para>
  254. You should be able to run
  255. <filename>php.exe</filename>
  256. on the command line.
  257. If you are not able to, first check the documentation that came with
  258. your
  259. <acronym>PHP</acronym>
  260. distribution, or ensure that the path to
  261. <filename>php.exe</filename>
  262. is in your
  263. Windows
  264. <constant>PATH</constant>
  265. environment variable.
  266. </para>
  267. <para>
  268. The next order of business is to ensure that Zend Framework
  269. library is set up correctly
  270. inside of the system
  271. <acronym>PHP</acronym>
  272. <property>include_path</property>
  273. . To find out where your
  274. <property>include_path</property>
  275. is located, you can type
  276. <command>php -i</command>
  277. and
  278. look for the
  279. <property>include_path</property>
  280. variable, or more succinctly
  281. execute
  282. <command>php -i | grep include_path</command>
  283. if you have Cygwin setup with
  284. grep available. Once you have found where your
  285. <property>include_path</property>
  286. is located (this will generally be
  287. something like
  288. <filename>C:\PHP\pear</filename>
  289. ,
  290. <filename>C:\PHP\share</filename>
  291. ,
  292. <filename>C:\Program%20Files\ZendServer\share</filename>
  293. or similar), ensure
  294. that the contents of the library/ directory are put inside your
  295. <property>include_path</property>
  296. specified directory.
  297. </para>
  298. <para>
  299. Once you have done those two things, you should be able to issue a
  300. command and get back
  301. the proper response like this:
  302. </para>
  303. <para>
  304. <inlinegraphic scale="100" align="center" valign="middle"
  305. fileref="figures/zend.tool.framework.cliversionwin32.png" format="PNG"/>
  306. </para>
  307. <para>
  308. If you do not see this type of output, go back and check your setup
  309. to ensure you have
  310. all of the necessary pieces in the proper place.
  311. </para>
  312. <para>
  313. There are a couple of alternative setups you might want to employ
  314. depending on your
  315. server's configuration, your level of access, or
  316. for other reasons.
  317. </para>
  318. <para>
  319. <emphasis>Alternative Setup</emphasis>
  320. involves keeping the Zend
  321. Framework download together as is, and altering both your
  322. system
  323. <constant>PATH</constant>
  324. as well as the
  325. <filename>php.ini</filename>
  326. file.
  327. In your user's environment, make sure to add
  328. <filename>C:\Path\To\ZendFramework\bin</filename>
  329. , so that your
  330. <filename>zf.bat</filename>
  331. file is executable. Also, alter the
  332. <filename>php.ini</filename>
  333. file to ensure that
  334. <filename>C:\Path\To\ZendFramework\library</filename>
  335. is in your
  336. <property>include_path</property>
  337. .
  338. </para>
  339. </sect2>
  340. <sect2 id="zend.tool.framework.clitool.setup-othernotes">
  341. <title>Other Setup Considerations</title>
  342. <para>
  343. If for some reason you do not want Zend Framework library inside
  344. your
  345. <property>include_path</property>
  346. , there is another option. There are
  347. two special environment variables that
  348. <filename>zf.php</filename>
  349. will
  350. utilize to determine the location of your Zend Framework
  351. installation.
  352. </para>
  353. <para>
  354. The first is
  355. <constant>ZEND_TOOL_INCLUDE_PATH_PREPEND</constant>
  356. , which will
  357. prepend the value of this environment variable to the system
  358. (
  359. <filename>php.ini</filename>
  360. )
  361. <property>include_path</property>
  362. before loading the
  363. client.
  364. </para>
  365. <para>
  366. Alternatively, you might want to use
  367. <constant>ZEND_TOOL_INCLUDE_PATH</constant>
  368. to completely
  369. <emphasis>replace</emphasis>
  370. the system
  371. <property>include_path</property>
  372. for one that makes sense specifically for the
  373. <command>zf</command>
  374. command line tool.
  375. </para>
  376. </sect2>
  377. <sect2 id="zend.tool.framework.clitool.continuing">
  378. <title>Where To Go Next?</title>
  379. <para>
  380. At this point, you should be set up to start initiating some more
  381. "interesting" commands.
  382. To get going, you can issue the
  383. <command>zf --help</command>
  384. command to see what is available to you.
  385. </para>
  386. <para>
  387. <inlinegraphic scale="100" align="center" valign="middle"
  388. fileref="figures/zend.tool.framework.clihelp.png" format="PNG"/>
  389. </para>
  390. <para>
  391. Continue on to the
  392. <classname>Zend_Tool_Project</classname>
  393. "Create Project"
  394. section to understand how to use the
  395. <command>zf</command>
  396. script for
  397. project creation.
  398. </para>
  399. </sect2>
  400. </sect1>