Zend_Tool-Usage-CLI.xml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.tool.usage.cli">
  4. <title>Using Zend_Tool On The Command Line</title>
  5. <para>
  6. The <acronym>CLI</acronym>, or command line tool (internally known as the console tool),
  7. is currently the primary interface for dispatching <classname>Zend_Tool</classname>
  8. requests. With the <acronym>CLI</acronym> tool, developers can issue tooling requests
  9. inside the "command line window", also commonly known as a "terminal" window. This
  10. environment is predominant in the *nix environment, but also has a common implementation
  11. in windows with the <filename>cmd.exe</filename>, console2 and also with the Cygwin project.
  12. </para>
  13. <!--
  14. <sect2 id="zend.tool.usage.cli.introduction">
  15. <title>Introduction</title>
  16. </sect2>
  17. -->
  18. <sect2 id="zend.tool.usage.cli.installation">
  19. <title>Installation</title>
  20. <sect3 id="zend.tool.usage.cli.installation.download-and-go">
  21. <title>Download And Go</title>
  22. <para>
  23. First download Zend Framework. This can be done by going to framework.zend.com
  24. and downloading the latest release. After you've downloaded the package and placed
  25. it on your system. The next step is to make the zf command available to your
  26. system. The easiest way to do this, is to copy the proper files from the bin/
  27. directory of the download, and place these files within the
  28. <emphasis>same</emphasis> directory as the location of the php cli binary.
  29. </para>
  30. </sect3>
  31. <sect3 id="zend.tool.usage.cli.installation.pear">
  32. <title>Installing Via Pear</title>
  33. <para>
  34. To install via PEAR, you must use the 3rd party zfcampus.org site to retrieve the
  35. latest Zend Framework PEAR package. These packages are typically built within a day
  36. of an official Zend Framework release. The benefit of installing via the PEAR
  37. package manager is that during the install process, the ZF library will end up on
  38. the include_path, and the zf.php and zf scripts will end up in a place on your
  39. system that will allow you to run them without any additional setup.
  40. </para>
  41. <programlisting language="text"><![CDATA[
  42. pear discover-channel pear.zfcampus.org
  43. pear install zfcampus/zf
  44. ]]></programlisting>
  45. <para>
  46. That is it. After the initial install, you should be able to continue on by
  47. running the zf command. Go good way to check to see if it't there is to run
  48. zf --help
  49. </para>
  50. </sect3>
  51. <sect3 id="zend.tool.usage.cli.installation.install-by-hand">
  52. <title>Installing by Hand</title>
  53. <para>
  54. Installing by hand refers to the process of forcing the zf.php and Zend Framework
  55. library to work together when they are placed in non-convential places, or at least,
  56. in a place that your system cannot dispatch from easily (typical of programs in your
  57. system PATH).
  58. </para>
  59. <para>
  60. If you are on a *nix or mac system, you can also create a link from somewhere in
  61. your path to the zf.sh file. If you do this, you do not need to worry about having
  62. Zend Framework's library on your include_path, as the zf.php and zf.sh files will
  63. be able to access the library relative to where they are (meaning the ./bin/ files
  64. are ../library/ relative to the Zend Framework library).
  65. </para>
  66. <para>
  67. There are a number of other options available for setting up the zf.php and library
  68. on your system. These options revolve around setting specific environment
  69. variables. These are described in the later section on "customizing the CLI
  70. environement". The environment variables for setting the zf.php include_path,
  71. ZF_INCLUDE_PATH and ZF_INCLUDE_PATH_PREPEND, are the ones of most interest.
  72. </para>
  73. </sect3>
  74. </sect2>
  75. <sect2 id="zend.tool.usage.cli.general-purpose-commands">
  76. <title>General Purpose Commands</title>
  77. <sect3 id="zend.tool.usage.cli.general-purpose-commands.version">
  78. <title>Version</title>
  79. <para>
  80. This will show the current version number of the copy of Zend Framework the zf.php
  81. tool is using.
  82. </para>
  83. <programlisting language="text"><![CDATA[
  84. zf show version
  85. ]]></programlisting>
  86. </sect3>
  87. <sect3 id="zend.tool.usage.cli.general-purpose-commands.built-in-help">
  88. <title>Built-in Help</title>
  89. <para>
  90. The built-in help system is the primary place where you can get up-to-date
  91. information on what your system is capable of doing. The help system is dynamic in
  92. that as providers are added to your system, they are automatically dispatchable, and
  93. as such, the parameters required to run them will be in the help screen. The
  94. easiest way to retrieve the help screen is the following:
  95. </para>
  96. <programlisting language="text"><![CDATA[
  97. zf --help
  98. ]]></programlisting>
  99. <para>
  100. This will give you an overview of the various capabilities of the system.
  101. Sometimes, there are more finite commands than can be run, and to gain more
  102. information about these, you might have to run a more specialized help command.
  103. For specialized help, simply replace any of the elements of the command with a "?".
  104. This will tell the help system that you want more information about what commands
  105. can go in place of the question mark. For example:
  106. </para>
  107. <programlisting language="text"><![CDATA[
  108. zf ? controller
  109. ]]></programlisting>
  110. <para>
  111. The above means "show me all 'actions' for the provider 'controller'"; while the
  112. following:
  113. </para>
  114. <programlisting language="text"><![CDATA[
  115. zf show ?
  116. ]]></programlisting>
  117. <para>
  118. means "show me all providers that support the 'show' action". This works for
  119. drilling down into options as well as you can see in the following examples:
  120. </para>
  121. <programlisting language="text"><![CDATA[
  122. zf show version.? (show any specialties)
  123. zf show version ? (show any options)
  124. ]]></programlisting>
  125. </sect3>
  126. <sect3 id="zend.tool.usage.cli.general-purpose-commands.manifest">
  127. <title>Manifest</title>
  128. <para>
  129. This will show what information is in the tooling systems manifest. This is more
  130. important for provider developers than casual users of the tooling system.
  131. </para>
  132. <programlisting language="text"><![CDATA[
  133. zf show manifest
  134. ]]></programlisting>
  135. </sect3>
  136. <!--
  137. <sect3 id="zend.tool.usage.cli.general-purpose-commands.tool-configuration">
  138. <title>Tool Configuration</title>
  139. <para>Placeholder need docs from @beberli </para>
  140. </sect3>
  141. -->
  142. </sect2>
  143. <sect2 id="zend.tool.usage.cli.project-specific-commands">
  144. <title>Project Specific Commands</title>
  145. <sect3 id="zend.tool.usage.cli.project-specific-commands.project">
  146. <title>Project</title>
  147. <para>
  148. The project provider is the first command you might want to run. This will setup the
  149. basic structure of your application. This is required before any of the other
  150. providers can be executed.
  151. </para>
  152. <programlisting language="text"><![CDATA[
  153. zf create project MyProjectName
  154. ]]></programlisting>
  155. <para>
  156. This will create a project in a directory called ./MyProjectName. From this point
  157. on, it is important to note that any subsequent commands on the command line must be
  158. issued from within the project directory you had just created. So, after creation,
  159. changing into that directory is required.
  160. </para>
  161. </sect3>
  162. <sect3 id="zend.tool.usage.cli.project-specific-commands.module">
  163. <title>Project</title>
  164. <para>
  165. The module provider allows for the easy creation of a Zend Framework module. A
  166. module follows the hMVC pattern loosely. When creating modules, it will take the
  167. same structure used at the application/ level, and duplicate it inside of the chosen
  168. name for your module, inside of the "modules" directory of the application/
  169. directory without duplicating the modules directory itself. For example:
  170. </para>
  171. <programlisting language="text"><![CDATA[
  172. zf create module Blog
  173. ]]></programlisting>
  174. <para>
  175. This will create a module named Blog at application/modules/Blog, and all of the
  176. artifacts that a module will need.
  177. </para>
  178. </sect3>
  179. <sect3 id="zend.tool.usage.cli.project-specific-commands.controller">
  180. <title>Controller</title>
  181. <para>
  182. The controller provider is responsible for creating (mostly) empty controllers as
  183. well as their corresponding view script directories and files. To utilize it to
  184. create an 'Auth' controlller, for example, execute:
  185. </para>
  186. <programlisting language="text"><![CDATA[
  187. zf create controller Auth
  188. ]]></programlisting>
  189. <para>
  190. This will create a controller named Auth, specifically it will create a file at
  191. application/controllers/AuthController.php with the AuthController inside.
  192. If you wish to create a controller for a module, use any of the following:
  193. </para>
  194. <programlisting language="text"><![CDATA[
  195. zf create controller Post 1 Blog
  196. zf create controller Post -m Blog
  197. zf create controller Post --module=Blog
  198. ]]></programlisting>
  199. <para>
  200. Note: In the first command, 1 is the value for the "includeIndexAction" flag.
  201. </para>
  202. </sect3>
  203. <sect3 id="zend.tool.usage.cli.project-specific-commands.action">
  204. <title>Action</title>
  205. <para>
  206. To create an action within an existing controller:
  207. </para>
  208. <programlisting language="text"><![CDATA[
  209. zf create action login Auth
  210. zf create action login -c Auth
  211. zf create action login --controller-name=Auth
  212. ]]></programlisting>
  213. </sect3>
  214. <sect3 id="zend.tool.usage.cli.project-specific-commands.view">
  215. <title>View</title>
  216. <para>
  217. To create a view outside of the normal controller/action creation, you would use
  218. one of the following:
  219. </para>
  220. <programlisting language="text"><![CDATA[
  221. zf create view Auth my-script-name
  222. zf create view -c Auth -a my-script-name
  223. ]]></programlisting>
  224. <para>
  225. This will create a view script in the controller folder of Auth.
  226. </para>
  227. </sect3>
  228. <sect3 id="zend.tool.usage.cli.project-specific-commands.model">
  229. <title>Model</title>
  230. <para>
  231. The model provider is only responsible for creating the proper model files,
  232. with the proper name inside the application folder. For example
  233. </para>
  234. <programlisting language="text"><![CDATA[
  235. zf create model User
  236. ]]></programlisting>
  237. <para>
  238. If you wish to create a model within a specific module:
  239. </para>
  240. <programlisting language="text"><![CDATA[
  241. zf create model Post -m Blog
  242. ]]></programlisting>
  243. <para>
  244. The above will create a 'Post' model inside of the 'Blog' module.
  245. </para>
  246. </sect3>
  247. <sect3 id="zend.tool.usage.cli.project-specific-commands.form">
  248. <title>Form</title>
  249. <para>
  250. The form provider is only responsible for creating the proper form file and
  251. init() method, with the proper name inside the application folder. For example:
  252. </para>
  253. <programlisting language="text"><![CDATA[
  254. zf create form Auth
  255. ]]></programlisting>
  256. <para>
  257. If you wish to create a model within a specific module:
  258. </para>
  259. <programlisting language="text"><![CDATA[
  260. zf create form Comment -m Blog
  261. ]]></programlisting>
  262. <para>
  263. The above will create a 'Comment' form inside of the 'Blog' module.
  264. </para>
  265. </sect3>
  266. <sect3 id="zend.tool.usage.cli.project-specific-commands.database-adapter">
  267. <title>DbAdapter</title>
  268. <para>
  269. To configure a DbAdapter, you will need to provide the information as a url
  270. encoded string. This string needs to be in quotes on the command line.
  271. </para>
  272. <para>
  273. For example, to enter the following information:
  274. <itemizedlist>
  275. <listitem>
  276. <para>adapter: Pdo_Mysql</para>
  277. </listitem>
  278. <listitem>
  279. <para>username: test</para>
  280. </listitem>
  281. <listitem>
  282. <para>password: test</para>
  283. </listitem>
  284. <listitem>
  285. <para>dbname: test </para>
  286. </listitem>
  287. </itemizedlist>
  288. The following will have to be run on the command line:
  289. </para>
  290. <programlisting language="text"><![CDATA[
  291. zf configure dbadapter "adapter=Pdo_Mysql&username=test&password=test&dbname=test"
  292. ]]></programlisting>
  293. <para>
  294. This assumes you wish to store this information inside of the
  295. 'production' space of the application configuration file. The following will
  296. demonstrate an sqlite configuration, in the 'development' section of the
  297. application config file.
  298. </para>
  299. <programlisting language="text"><![CDATA[
  300. zf configure dbadapter "adapter=Pdo_Sqlite&dbname=../data/test.db" development
  301. zf configure dbadapter "adapter=Pdo_Sqlite&dbname=../data/test.db" -s development
  302. ]]></programlisting>
  303. </sect3>
  304. <sect3 id="zend.tool.usage.cli.project-specific-commands.db-table">
  305. <title>DbTable</title>
  306. <para>
  307. The DbTable provider is responsible for creating Zend_Db_Table
  308. model/data access files for your application to consume, with the proper
  309. class name, and in the proper location in the application. The two
  310. important pieces of information are the <emphasis>DbTable name</emphasis>,
  311. and the <emphasis>actual database table name</emphasis>. For example:
  312. </para>
  313. <programlisting language="text"><![CDATA[
  314. zf create dbtable User user
  315. zf create dbtable User -a user
  316. // also accepts a force option to overwrite existing files
  317. zf create dbtable User user -f
  318. zf create dbtable User user --force-override
  319. ]]></programlisting>
  320. <para>
  321. The DbTable provider is also capable of creating the proper files by
  322. scanning the database configured with the above DbAdapter provider.
  323. </para>
  324. <programlisting language="text"><![CDATA[
  325. zf create dbtable.from-database
  326. ]]></programlisting>
  327. <para>
  328. When executing the above, it might make sense to use the pretend / "-p"
  329. flag first so that you can see what would be done, and what tables can
  330. be found in the database.
  331. </para>
  332. <programlisting language="text"><![CDATA[
  333. zf -p create dbtable.from-database
  334. ]]></programlisting>
  335. </sect3>
  336. <sect3 id="zend.tool.usage.cli.project-specific-commands.layout">
  337. <title>Layout</title>
  338. <para>
  339. Currently, the only supported action for layouts is simply to enable them
  340. will setup the proper keys in the application.ini file for the application
  341. resource to work, and create the proper directories and layout.phtml file.
  342. </para>
  343. <programlisting language="text"><![CDATA[
  344. zf enable layout
  345. ]]></programlisting>
  346. </sect3>
  347. </sect2>
  348. <sect2 id="zend.tool.usage.cli.environment-customization">
  349. <title>Environment Customization</title>
  350. <sect3 id="zend.tool.usage.cli.environment-customization.storage-directory">
  351. <title>The Storage Directory</title>
  352. <para>
  353. The storage directory is important so that providers may have a place to find
  354. custom user generated logic that might change the way they behave. One example
  355. can be found below is the placement of a custom project profile file.
  356. </para>
  357. <programlisting language="text"><![CDATA[
  358. zf --setup storage-directory
  359. ]]></programlisting>
  360. </sect3>
  361. <sect3 id="zend.tool.usage.cli.environment-customization.configuration-file">
  362. <title>The Configuration File</title>
  363. <para>
  364. This will create the proper zf.ini file. This <emphasis>should</emphasis>
  365. be run after <code>zf --setup storage-directory</code>. If it is not, it will
  366. be located inside the users home directory. If it is, it will be located inside
  367. the users storage directory.
  368. </para>
  369. <programlisting language="text"><![CDATA[
  370. zf --setup config-file
  371. ]]></programlisting>
  372. </sect3>
  373. <sect3 id="zend.tool.usage.cli.environment-customization.environment-locations">
  374. <title>Environment Locations</title>
  375. <para>
  376. These should be set if you wish to override the default places where zf will
  377. attempt to read their values.
  378. </para>
  379. <itemizedlist>
  380. <listitem>
  381. <para>ZF_HOME</para>
  382. <itemizedlist>
  383. <listitem>
  384. <para>the directory this tool will look for a home directory</para>
  385. </listitem>
  386. <listitem><para>directory must exist</para></listitem>
  387. <listitem>
  388. <para>search order:</para>
  389. <itemizedlist>
  390. <listitem><para>ZF_HOME environment variable</para></listitem>
  391. <listitem><para>HOME environment variable</para></listitem>
  392. <listitem><para>then HOMEPATH environment variable</para></listitem>
  393. </itemizedlist>
  394. </listitem>
  395. </itemizedlist>
  396. </listitem>
  397. <listitem>
  398. <para>ZF_STORAGE_DIRECTORY</para>
  399. <itemizedlist>
  400. <listitem>
  401. <para>where this tool will look for a storage directory</para>
  402. </listitem>
  403. <listitem><para>directory must exist</para></listitem>
  404. <listitem>
  405. <para>search order:</para>
  406. <itemizedlist>
  407. <listitem>
  408. <para>ZF_STORAGE_DIRECTORY environment variable</para>
  409. </listitem>
  410. <listitem><para>$homeDirectory/.zf/ directory</para></listitem>
  411. </itemizedlist>
  412. </listitem>
  413. </itemizedlist>
  414. </listitem>
  415. <listitem>
  416. <para>ZF_CONFIG_FILE</para>
  417. <itemizedlist>
  418. <listitem>
  419. <para>where this tool will look for a configuration file</para>
  420. </listitem>
  421. <listitem>
  422. <para>search order:</para>
  423. <itemizedlist>
  424. <listitem>
  425. <para>ZF_CONFIG_FILE environment variable</para>
  426. </listitem>
  427. <listitem>
  428. <para>$homeDirectory/.zf.ini file if it exists</para>
  429. </listitem>
  430. <listitem>
  431. <para>$storageDirectory/zf.ini file if it exists</para>
  432. </listitem>
  433. </itemizedlist>
  434. </listitem>
  435. </itemizedlist>
  436. </listitem>
  437. <listitem>
  438. <para>ZF_INCLUDE_PATH</para>
  439. <itemizedlist>
  440. <listitem>
  441. <para>set the include_path for this tool to use this value</para>
  442. </listitem>
  443. <listitem>
  444. <para>original behavior:</para>
  445. <itemizedlist>
  446. <listitem><para>use php's include_path to find ZF</para></listitem>
  447. <listitem>
  448. <para>use the ZF_INCLUDE_PATH environment variable</para>
  449. </listitem>
  450. <listitem>
  451. <para>
  452. use the path ../library (relative to zf.php) to find ZF
  453. </para>
  454. </listitem>
  455. </itemizedlist>
  456. </listitem>
  457. </itemizedlist>
  458. </listitem>
  459. <listitem>
  460. <para>ZF_INCLUDE_PATH_PREPEND</para>
  461. <itemizedlist>
  462. <listitem>
  463. <para>prepend the current php.ini include_path with this value</para>
  464. </listitem>
  465. </itemizedlist>
  466. </listitem>
  467. </itemizedlist>
  468. </sect3>
  469. </sect2>
  470. </sect1>