Zend_Tool-Usage-CLI.xml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  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 system.
  26. The easiest way to do this, is to copy the proper files from the bin/ directory
  27. of the download, and place these files within the <emphasis>same</emphasis> directory
  28. 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 package
  37. manager is that during the install process, the ZF library will end up on the
  38. include_path, and the zf.php and zf scripts will end up in a place on your system
  39. 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 your
  61. 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 variables.
  69. These are described in the later section on "customizing the CLI environement". The
  70. environment variables for setting the zf.php include_path, ZF_INCLUDE_PATH and
  71. 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 tool is using.
  81. </para>
  82. <programlisting language="text"><![CDATA[
  83. zf show version
  84. ]]></programlisting>
  85. </sect3>
  86. <sect3 id="zend.tool.usage.cli.general-purpose-commands.built-in-help">
  87. <title>Built-in Help</title>
  88. <para>
  89. The built-in help system is the primary place where you can get up-to-date information
  90. on what your system is capable of doing. The help system is dynamic in that as providers
  91. are added to your system, they are automatically dispatchable, and as such, the parameters
  92. required to run them will be in the help screen. The easiest way to retrieve the help
  93. screen is the following:
  94. </para>
  95. <programlisting language="text"><![CDATA[
  96. zf --help
  97. ]]></programlisting>
  98. <para>
  99. This will give you an overview of the various capabilities of the system. Sometimes, there
  100. are more finite commands than can be run, and to gain more information about these, you might
  101. have to run a more specialized help command. For specialized help, simply replace any of the
  102. elements of the command with a "?". This will tell the help system that you want more
  103. information about what commands can go in place of the question mark. For example:
  104. </para>
  105. <programlisting language="text"><![CDATA[
  106. zf ? controller
  107. ]]></programlisting>
  108. <para>
  109. The above means "show me all 'actions' for the provider 'controller'"; while the following:
  110. </para>
  111. <programlisting language="text"><![CDATA[
  112. zf show ?
  113. ]]></programlisting>
  114. <para>
  115. means "show me all providers that support the 'show' action". This works for drilling down
  116. into options as well as you can see in the following examples:
  117. </para>
  118. <programlisting language="text"><![CDATA[
  119. zf show version.? (show any specialties)
  120. zf show version ? (show any options)
  121. ]]></programlisting>
  122. </sect3>
  123. <sect3 id="zend.tool.usage.cli.general-purpose-commands.manifest">
  124. <title>Manifest</title>
  125. <para>
  126. This will show what information is in the tooling systems manifest. This is more important
  127. for provider developers than casual users of the tooling system.
  128. </para>
  129. <programlisting language="text"><![CDATA[
  130. zf show manifest
  131. ]]></programlisting>
  132. </sect3>
  133. <!--
  134. <sect3 id="zend.tool.usage.cli.general-purpose-commands.tool-configuration">
  135. <title>Tool Configuration</title>
  136. <para>Placeholder need docs from @beberli </para>
  137. </sect3>
  138. -->
  139. </sect2>
  140. <sect2 id="zend.tool.usage.cli.project-specific-commands">
  141. <title>Project Specific Commands</title>
  142. <sect3 id="zend.tool.usage.cli.project-specific-commands.project">
  143. <title>Project</title>
  144. <para>
  145. The project provider is the first command you might want to run. This will setup the basic
  146. structure of your application. This is required before any of the other providers can
  147. be executed.
  148. </para>
  149. <programlisting language="text"><![CDATA[
  150. zf create project MyProjectName
  151. ]]></programlisting>
  152. <para>
  153. This will create a project in a directory called ./MyProjectName. From this point on,
  154. it is important to note that any subsequent commands on the command line must be issued
  155. from within the project directory you had just created. So, after creation, changing into
  156. that directory is required.
  157. </para>
  158. </sect3>
  159. <sect3 id="zend.tool.usage.cli.project-specific-commands.module">
  160. <title>Project</title>
  161. <para>
  162. The module provider allows for the easy creation of a Zend Framework module. A module
  163. follows the hMVC pattern loosely. When creating modules, it will take the same structure
  164. used at the application/ level, and duplicate it inside of the chosen name for your module,
  165. inside of the "modules" directory of the application/ directory without duplicating the
  166. modules directory itself. For example:
  167. </para>
  168. <programlisting language="text"><![CDATA[
  169. zf create module Blog
  170. ]]></programlisting>
  171. <para>
  172. This will create a module named Blog at application/modules/Blog, and all of the artifacts
  173. that a module will need.
  174. </para>
  175. </sect3>
  176. <sect3 id="zend.tool.usage.cli.project-specific-commands.controller">
  177. <title>Controller</title>
  178. <para>
  179. The controller provider is responsible for creating (mostly) empty controllers as well
  180. as their corresponding view script directories and files. To utilize it to create
  181. an 'Auth' controlller, for example, execute:
  182. </para>
  183. <programlisting language="text"><![CDATA[
  184. zf create controller Auth
  185. ]]></programlisting>
  186. <para>
  187. This will create a controller named Auth, specifically it will create a file at
  188. application/controllers/AuthController.php with the AuthController inside.
  189. If you wish to create a controller for a module, use any of the following:
  190. </para>
  191. <programlisting language="text"><![CDATA[
  192. zf create controller Post 1 Blog
  193. zf create controller Post -m Blog
  194. zf create controller Post --module=Blog
  195. ]]></programlisting>
  196. <para>
  197. Note: In the first command, 1 is the value for the "includeIndexAction" flag.
  198. </para>
  199. </sect3>
  200. <sect3 id="zend.tool.usage.cli.project-specific-commands.action">
  201. <title>Action</title>
  202. <para>
  203. To create an action within an existing controller:
  204. </para>
  205. <programlisting language="text"><![CDATA[
  206. zf create action login Auth
  207. zf create action login -c Auth
  208. zf create action login --controller-name=Auth
  209. ]]></programlisting>
  210. </sect3>
  211. <sect3 id="zend.tool.usage.cli.project-specific-commands.view">
  212. <title>View</title>
  213. <para>
  214. To create a view outside of the normal controller/action creation, you would use
  215. one of the following:
  216. </para>
  217. <programlisting language="text"><![CDATA[
  218. zf create view Auth my-script-name
  219. zf create view -c Auth -a my-script-name
  220. ]]></programlisting>
  221. <para>
  222. This will create a view script in the controller folder of Auth.
  223. </para>
  224. </sect3>
  225. <sect3 id="zend.tool.usage.cli.project-specific-commands.model">
  226. <title>Model</title>
  227. <para>
  228. The model provider is only responsible for creating the proper model files,
  229. with the proper name inside the application folder. For example
  230. </para>
  231. <programlisting language="text"><![CDATA[
  232. zf create model User
  233. ]]></programlisting>
  234. <para>
  235. If you wish to create a model within a specific module:
  236. </para>
  237. <programlisting language="text"><![CDATA[
  238. zf create model Post -m Blog
  239. ]]></programlisting>
  240. <para>
  241. The above will create a 'Post' model inside of the 'Blog' module.
  242. </para>
  243. </sect3>
  244. <sect3 id="zend.tool.usage.cli.project-specific-commands.form">
  245. <title>Form</title>
  246. <para>
  247. The form provider is only responsible for creating the proper form file and
  248. init() method, with the proper name inside the application folder. For example:
  249. </para>
  250. <programlisting language="text"><![CDATA[
  251. zf create form Auth
  252. ]]></programlisting>
  253. <para>
  254. If you wish to create a model within a specific module:
  255. </para>
  256. <programlisting language="text"><![CDATA[
  257. zf create form Comment -m Blog
  258. ]]></programlisting>
  259. <para>
  260. The above will create a 'Comment' form inside of the 'Blog' module.
  261. </para>
  262. </sect3>
  263. <sect3 id="zend.tool.usage.cli.project-specific-commands.database-adapter">
  264. <title>DbAdapter</title>
  265. <para>
  266. To configure a DbAdapter, you will need to provide the information as a url
  267. encoded string. This string needs to be in quotes on the command line.
  268. </para>
  269. <para>
  270. For example, to enter the following information:
  271. <itemizedlist>
  272. <listitem>
  273. <para>adapter: Pdo_Mysql</para>
  274. </listitem>
  275. <listitem>
  276. <para>username: test</para>
  277. </listitem>
  278. <listitem>
  279. <para>password: test</para>
  280. </listitem>
  281. <listitem>
  282. <para>dbname: test </para>
  283. </listitem>
  284. </itemizedlist>
  285. The following will have to be run on the command line:
  286. </para>
  287. <programlisting language="text"><![CDATA[
  288. zf configure dbadapter "adapter=Pdo_Mysql&username=test&password=test&dbname=test"
  289. ]]></programlisting>
  290. <para>
  291. This assumes you wish to store this information inside of the
  292. 'production' space of the application configuration file. The following will
  293. demonstrate an sqlite configuration, in the 'development' section of the
  294. application config file.
  295. </para>
  296. <programlisting language="text"><![CDATA[
  297. zf configure dbadapter "adapter=Pdo_Sqlite&dbname=../data/test.db" development
  298. zf configure dbadapter "adapter=Pdo_Sqlite&dbname=../data/test.db" -s development
  299. ]]></programlisting>
  300. </sect3>
  301. <sect3 id="zend.tool.usage.cli.project-specific-commands.db-table">
  302. <title>DbTable</title>
  303. <para>
  304. The DbTable provider is responsible for creating Zend_Db_Table
  305. model/data access files for your application to consume, with the proper
  306. class name, and in the proper location in the application. The two
  307. important pieces of information are the <emphasis>DbTable name</emphasis>,
  308. and the <emphasis>actual database table name</emphasis>. For example:
  309. </para>
  310. <programlisting language="text"><![CDATA[
  311. zf create dbtable User user
  312. zf create dbtable User -a user
  313. // also accepts a force option to overwrite existing files
  314. zf create dbtable User user -f
  315. zf create dbtable User user --force-override
  316. ]]></programlisting>
  317. <para>
  318. The DbTable provider is also capable of creating the proper files by
  319. scanning the database configured with the above DbAdapter provider.
  320. </para>
  321. <programlisting language="text"><![CDATA[
  322. zf create dbtable.from-database
  323. ]]></programlisting>
  324. <para>
  325. When executing the above, it might make sense to use the pretend / "-p"
  326. flag first so that you can see what would be done, and what tables can
  327. be found in the database.
  328. </para>
  329. <programlisting language="text"><![CDATA[
  330. zf -p create dbtable.from-database
  331. ]]></programlisting>
  332. </sect3>
  333. <sect3 id="zend.tool.usage.cli.project-specific-commands.layout">
  334. <title>Layout</title>
  335. <para>
  336. Currently, the only supported action for layouts is simply to enable them
  337. will setup the proper keys in the application.ini file for the application
  338. resource to work, and create the proper directories and layout.phtml file.
  339. </para>
  340. <programlisting language="text"><![CDATA[
  341. zf enable layout
  342. ]]></programlisting>
  343. </sect3>
  344. </sect2>
  345. <sect2 id="zend.tool.usage.cli.environment-customization">
  346. <title>Environment Customization</title>
  347. <sect3 id="zend.tool.usage.cli.environment-customization.storage-directory">
  348. <title>The Storage Directory</title>
  349. <para>
  350. The storage directory is important so that providers may have a place to find
  351. custom user generated logic that might change the way they behave. One example
  352. can be found below is the placement of a custom project profile file.
  353. </para>
  354. <programlisting language="text"><![CDATA[
  355. zf --setup storage-directory
  356. ]]></programlisting>
  357. </sect3>
  358. <sect3 id="zend.tool.usage.cli.environment-customization.configuration-file">
  359. <title>The Configuration File</title>
  360. <para>
  361. This will create the proper zf.ini file. This <emphasis>should</emphasis>
  362. be run after <code>zf --setup storage-directory</code>. If it is not, it will
  363. be located inside the users home directory. If it is, it will be located inside
  364. the users storage directory.
  365. </para>
  366. <programlisting language="text"><![CDATA[
  367. zf --setup config-file
  368. ]]></programlisting>
  369. </sect3>
  370. <sect3 id="zend.tool.usage.cli.environment-customization.environment-locations">
  371. <title>Environment Locations</title>
  372. <para>
  373. These should be set if you wish to override the default places where zf will
  374. attempt to read their values.
  375. </para>
  376. <itemizedlist>
  377. <listitem>
  378. <para>ZF_HOME</para>
  379. <itemizedlist>
  380. <listitem><para>the directory this tool will look for a home directory</para></listitem>
  381. <listitem><para>directory must exist</para></listitem>
  382. <listitem>
  383. <para>search order:</para>
  384. <itemizedlist>
  385. <listitem><para>ZF_HOME environment variable</para></listitem>
  386. <listitem><para>HOME environment variable</para></listitem>
  387. <listitem><para>then HOMEPATH environment variable</para></listitem>
  388. </itemizedlist>
  389. </listitem>
  390. </itemizedlist>
  391. </listitem>
  392. <listitem>
  393. <para>ZF_STORAGE_DIRECTORY</para>
  394. <itemizedlist>
  395. <listitem><para>where this tool will look for a storage directory</para></listitem>
  396. <listitem><para>directory must exist</para></listitem>
  397. <listitem>
  398. <para>search order:</para>
  399. <itemizedlist>
  400. <listitem><para>ZF_STORAGE_DIRECTORY environment variable</para></listitem>
  401. <listitem><para>$homeDirectory/.zf/ directory</para></listitem>
  402. </itemizedlist>
  403. </listitem>
  404. </itemizedlist>
  405. </listitem>
  406. <listitem>
  407. <para>ZF_CONFIG_FILE</para>
  408. <itemizedlist>
  409. <listitem><para>where this tool will look for a configuration file</para></listitem>
  410. <listitem>
  411. <para>search order:</para>
  412. <itemizedlist>
  413. <listitem><para>ZF_CONFIG_FILE environment variable</para></listitem>
  414. <listitem><para>$homeDirectory/.zf.ini file if it exists</para></listitem>
  415. <listitem><para>$storageDirectory/zf.ini file if it exists</para></listitem>
  416. </itemizedlist>
  417. </listitem>
  418. </itemizedlist>
  419. </listitem>
  420. <listitem>
  421. <para>ZF_INCLUDE_PATH</para>
  422. <itemizedlist>
  423. <listitem><para>set the include_path for this tool to use this value</para></listitem>
  424. <listitem>
  425. <para>original behavior:</para>
  426. <itemizedlist>
  427. <listitem><para>use php's include_path to find ZF</para></listitem>
  428. <listitem><para>use the ZF_INCLUDE_PATH environment variable</para></listitem>
  429. <listitem><para>use the path ../library (relative to zf.php) to find ZF</para></listitem>
  430. </itemizedlist>
  431. </listitem>
  432. </itemizedlist>
  433. </listitem>
  434. <listitem>
  435. <para>ZF_INCLUDE_PATH_PREPEND</para>
  436. <itemizedlist>
  437. <listitem><para>prepend the current php.ini include_path with this value</para></listitem>
  438. </itemizedlist>
  439. </listitem>
  440. </itemizedlist>
  441. </sect3>
  442. </sect2>
  443. </sect1>