1 <?xml version="1.0" encoding="UTF-8"?>
2 <!-- EN-Revision: 16656 -->
4 <sect1 id="zend.tool.framework.clitool">
5 <title>Usando la herramienta CLI</title>
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>
14 <acronym>CLI</acronym>
15 tool, developers can issue tooling requests
16 inside the "command line windows", also commonly
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.
24 <sect2 id="zend.tool.framework.clitool.setup-general">
25 <title>Setting up the CLI tool</title>
28 To issue tooling requests via the command line client, you first
30 client so that your system can handle the "zf"
31 command. The command line client, for all
32 intents and purposes, is
34 <filename>.sh</filename>
36 <filename>.bat</filename>
37 file that is provided with
38 your Zend Framework distribution. In trunk, it can be found
40 <ulink url="http://framework.zend.com/svn/framework/standard/trunk/bin/">
41 http://framework.zend.com/svn/framework/standard/trunk/bin/
47 As you can see, there are 3 files in the
48 <filename>/bin/</filename>
50 <filename>zf.php</filename>
52 <filename>zf.sh</filename>
54 <filename>zf.bat</filename>
56 <filename>zf.sh</filename>
58 <filename>zf.bat</filename>
59 are the operating system specific client
61 <filename>zf.sh</filename>
62 for the *nix environment, and
63 <filename>zf.bat</filename>
64 for the Win32 environment. These client wrappers are
65 responsible for finding the proper
66 <filename>php.exe</filename>
68 <filename>zf.php</filename>
69 , and passing on the client request. The
70 <filename>zf.php</filename>
71 is the responsible for handling understanding
72 your environment, constructing the proper
73 include_path, and passing
74 what is provided on the command line to the proper library
80 Ultimately, you want to ensure two things to make everything work
82 operating system you are on:
88 <filename>zf.sh/zf.bat</filename>
89 is reachable from your system
90 path. This is the ability to call
93 anywhere on your command line, regardless of what your
100 <filename>ZendFramework/library</filename>
102 <property>include_path</property>
110 Note: while the above are the most ideal
111 requirements, you can simply download Zend
112 Framework and expect it
114 <filename>./path/to/zf.php</filename>
121 <sect2 id="zend.tool.framework.clitool.setup-starnix">
122 <title>Setting up the CLI tool on Unix-like Systems</title>
125 The most common setup in the *nix environment, is to copy the
126 <filename>zf.sh</filename>
128 <filename>zf.php</filename>
129 into the same directory
131 <acronym>PHP</acronym>
132 binary. This can generally be found in one of the
136 <programlisting language="text"><![CDATA[
139 /usr/local/ZendServer/bin/
140 /Applications/ZendServer/bin/
144 To find out the location of your
145 <acronym>PHP</acronym>
146 binary, you can execute 'which
147 php' on the command line. This will return the location of
149 <acronym>PHP</acronym>
150 binary you will be using to run
151 <acronym>PHP</acronym>
152 scripts in this environment.
156 The next order of business is to ensure that Zend Framework
157 library is set up correctly
159 <acronym>PHP</acronym>
160 <property>include_path</property>
161 . To find out where your
162 <property>include_path</property>
163 is located, you can execute
164 <command>php -i</command>
166 <property>include_path</property>
167 variable, or more succinctly,
169 <command>php -i | grep include_path</command>
170 . Once you have found where
172 <property>include_path</property>
173 is located (this will generally be
175 <filename>/usr/lib/php</filename>
177 <filename>/usr/share/php</filename>
179 <filename>/usr/local/lib/php</filename>
180 , or similar), ensure that the contents of the
181 <filename>/library/</filename>
184 <property>include_path</property>
189 Once you have done those two things, you should be able to issue a
191 the proper response like this:
195 <inlinegraphic scale="100" align="center" valign="middle"
196 fileref="figures/zend.tool.framework.cliversionunix.png" format="PNG"/>
200 If you do not see this type of output, go back and check your setup
202 all of the necessary pieces in the proper place.
206 There are a couple of alternative setups you might want to employ
208 servers configuration, your level of access, or
213 <emphasis>Alternative Setup</emphasis>
214 involves keeping the Zend
215 Framework download together as is, and creating a link from a
216 <constant>PATH</constant>
218 <filename>zf.sh</filename>
219 . What this means is you can
220 place the contents of the ZendFramework download into a
223 <filename>/usr/local/share/ZendFramework</filename>
226 <filename>/home/username/lib/ZendFramework</filename>
229 <filename>zf.sh</filename>
234 Assuming you want to put the link inside
235 <filename>/usr/local/bin</filename>
236 (this could also work for placing the link inside
237 <filename>/home/username/bin/</filename>
238 for example) you would issue a
239 command similar to this:
242 <programlisting language="sh"><![CDATA[
243 ln -s /usr/local/share/ZendFramework/bin/zf.sh /usr/local/bin/zf
246 ln -s /home/username/lib/ZendFramework/bin/zf.sh /home/username/bin/zf
250 This will create a link which you should be able to access globally
257 <sect2 id="zend.tool.framework.clitool.setup-windows">
258 <title>Setting up the CLI tool on Windows</title>
261 The most common setup in the Windows Win32 environment, is to copy
263 <filename>zf.bat</filename>
265 <filename>zf.php</filename>
268 <acronym>PHP</acronym>
269 binary. This can generally be found in one of
270 the following places:
273 <programlisting language="text"><![CDATA[
275 C:\Program Files\ZendServer\bin\
280 You should be able to run
281 <filename>php.exe</filename>
283 If you are not able to, first check the documentation that came with
285 <acronym>PHP</acronym>
286 distribution, or ensure that the path to
287 <filename>php.exe</filename>
290 <constant>PATH</constant>
291 environment variable.
295 The next order of business is to ensure that Zend Framework
296 library is set up correctly
298 <acronym>PHP</acronym>
299 <property>include_path</property>
300 . To find out where your
301 <property>include_path</property>
302 is located, you can type
303 <command>php -i</command>
306 <property>include_path</property>
307 variable, or more succinctly
309 <command>php -i | grep include_path</command>
310 if you have Cygwin setup with
311 grep available. Once you have found where your
312 <property>include_path</property>
313 is located (this will generally be
315 <filename>C:\PHP\pear</filename>
317 <filename>C:\PHP\share</filename>
319 <filename>C:\Program%20Files\ZendServer\share</filename>
321 that the contents of the library/ directory are put inside your
322 <property>include_path</property>
327 Once you have done those two things, you should be able to issue a
329 the proper response like this:
333 <inlinegraphic scale="100" align="center" valign="middle"
334 fileref="figures/zend.tool.framework.cliversionwin32.png" format="PNG"/>
338 If you do not see this type of output, go back and check your setup
340 all of the necessary pieces in the proper place.
344 There are a couple of alternative setups you might want to employ
346 server's configuration, your level of access, or
351 <emphasis>Alternative Setup</emphasis>
352 involves keeping the Zend
353 Framework download together as is, and altering both your
355 <constant>PATH</constant>
357 <filename>php.ini</filename>
359 In your user's environment, make sure to add
360 <filename>C:\Path\To\ZendFramework\bin</filename>
362 <filename>zf.bat</filename>
363 file is executable. Also, alter the
364 <filename>php.ini</filename>
366 <filename>C:\Path\To\ZendFramework\library</filename>
368 <property>include_path</property>
374 <sect2 id="zend.tool.framework.clitool.setup-othernotes">
375 <title>Other Setup Considerations</title>
378 If for some reason you do not want Zend Framework library inside
380 <property>include_path</property>
381 , there is another option. There are
382 two special environment variables that
383 <filename>zf.php</filename>
385 utilize to determine the location of your Zend Framework
391 <constant>ZEND_TOOL_INCLUDE_PATH_PREPEND</constant>
393 prepend the value of this environment variable to the system
395 <filename>php.ini</filename>
397 <property>include_path</property>
403 Alternatively, you might want to use
404 <constant>ZEND_TOOL_INCLUDE_PATH</constant>
406 <emphasis>replace</emphasis>
408 <property>include_path</property>
409 for one that makes sense specifically for the
410 <command>zf</command>
415 <sect2 id="zend.tool.framework.clitool.continuing">
416 <title>Where To Go Next?</title>
419 At this point, you should be set up to start initiating some more
420 "interesting" commands.
421 To get going, you can issue the
422 <command>zf --help</command>
423 command to see what is available to you.
427 <inlinegraphic scale="100" align="center" valign="middle"
428 fileref="figures/zend.tool.framework.clihelp.png" format="PNG"/>
433 <classname>Zend_Tool_Project</classname>
435 section to understand how to use the
436 <command>zf</command>