Zend_Tool-Usage-CLI.xml 22 KB

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