Zend_Tool-Usage-CLI.xml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- EN-Revision: 19777 -->
  3. <!-- Reviewed: no -->
  4. <sect1 id="zend.tool.usage.cli">
  5. <title>Verwendung von Zend_Tool auf der Kommandozeile</title>
  6. <para>
  7. Das <acronym>CLI</acronym>, oder Kommandozeilentool (intern bekannt als Konsolen Tool),
  8. ist aktuell das primäre Interface für die Bearbeitung von <classname>Zend_Tool</classname>
  9. Anfragen. Mit dem <acronym>CLI</acronym> Tool können Entwickler Tooling Anfragen im
  10. "Kommandozeilen Fenster", auch bekannt als "Terminal" Fenster, auslösen. Diese Umgebung ist
  11. vorherrschend bei *nix Umgebungen, es gibt aber auch übliche Implementationen unter Windows
  12. mit <filename>cmd.exe</filename>, Console2 und auch im Cygwin Projekt.
  13. </para>
  14. <!--
  15. <sect2 id="zend.tool.usage.cli.introduction">
  16. <title>Einführung</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>Herunterladen und anfangen</title>
  23. <para>
  24. Zuerst muss Zend Framework heruntergeladen werden. Das kann man tun, indem man auf
  25. framework.zend.com geht und das letzte Release herunterlädt. Nachdem man das
  26. Paket heruntergeladen und auf dem System plaziert hat ist der nächste Schritt das
  27. zf Kommendo auf dem System zu erstellen. Der einfachste Weg das zu tun ist die
  28. richtigen Dateien vom bin/ Verzeichnis des Downloads zu kopieren, und diese Dateien
  29. im <emphasis>gleichen</emphasis> Verzeichnis zu platzieren wie der Ort an dem die
  30. PHP CLI Binardatei ist.
  31. </para>
  32. </sect3>
  33. <sect3 id="zend.tool.usage.cli.installation.pear">
  34. <title>Installation über Pear</title>
  35. <para>
  36. Um es über PEAR zu installieren muss man die 3rd Party Site zfcampus.org verwenden
  37. und das letzte Zend Framwork PEAR Paket empfangen. Diese Pakete werden
  38. typischerweise innerhalb eines Tages nach einem offiziellen Zend Framework Release
  39. erstellt. Der Vorteil der Installation über den PEAR Package Manager ist, dass die
  40. ZF Bibliothek im include_path endet, und die zf.php und ZF Skripte an einem Ort im
  41. eigenen System enden der es erlaubt Sie ohne zusätzliches Setup zu starten.
  42. </para>
  43. <programlisting language="text"><![CDATA[
  44. pear discover-channel pear.zfcampus.org
  45. pear install zfcampus/zf
  46. ]]></programlisting>
  47. <para>
  48. Das ist es schon. Nachdem initialen Setup sollte man in der Lage sein weiter zu
  49. machen indem das zf Kommando ausgeführt wird. Ein gute Weg um zu prüfen ob es
  50. vorhanden ist, ist es zf --help auszuführen.
  51. </para>
  52. </sect3>
  53. <sect3 id="zend.tool.usage.cli.installation.install-by-hand">
  54. <title>Installation von Hand</title>
  55. <para>
  56. Die Installtion von Hand zeigt den Prozess um zf.php und die Zend Framework
  57. Bibliothek dazu zu zwingen zusammen zu arbeiten wenn diese nicht auf konventionellen
  58. Orten abgelegt wurden, oder zumindest, an einem Ort an dem das eigene System diese
  59. nicht einfach ausführen kann (typisch für Programme im eigenen System Pfad).
  60. </para>
  61. <para>
  62. Wenn man auf einem *nix oder Mac System ist, kann man auch einen Link von irgendwo im
  63. eigenen Pfad zur zf.sh Datei erstellen. Wenn man das macht muss man sich keine
  64. Gedanken darüber machen das die Zend Framework Bibliothek im eigenen include_path
  65. ist, da die Dateien zf.php und zf.sh auf die Bibliothek, relativ dazu wo Sie sind,
  66. zugreifen können (was bedeutet das die ./bin/ Dateien relativ zu ../library/ der
  67. Zend Framework Bibliothek sind).
  68. </para>
  69. <para>
  70. Es gibt eine Anzahl von anderen vorhandenen Optionen für das Setup von zf.php und
  71. der Bibliothek im eigenen System. Diese Optionen drehen sich um das Setzen von
  72. speziellen Umgebungsvariablen. Diese werden im späteren Kapitel "Die CLI Umgebung
  73. anpassen" beschrieben. Die Umgebungsvariablen für das Setzen von include_path,
  74. ZF_INCLUDE_PATH und ZF_INCLUDE_PATH_PREPEND für zf.php sind die interessantesten.
  75. </para>
  76. </sect3>
  77. </sect2>
  78. <sect2 id="zend.tool.usage.cli.general-purpose-commands">
  79. <title>Kommandos für generelle Zwecke</title>
  80. <sect3 id="zend.tool.usage.cli.general-purpose-commands.version">
  81. <title>Version</title>
  82. <para>
  83. Das zeigt die aktuelle Versionsnummer der Kopie vom Zend Framework welche das zf.php
  84. Tool verwendet.
  85. </para>
  86. <programlisting language="text"><![CDATA[
  87. zf show version
  88. ]]></programlisting>
  89. </sect3>
  90. <sect3 id="zend.tool.usage.cli.general-purpose-commands.built-in-help">
  91. <title>Eingebaute Hilfe</title>
  92. <para>
  93. Das eingebaute Hilfe System ist der primäre Ort von dem man up-to-date Informationen
  94. darüber erhält was das eigene System in der Lage ist zu tun. Das Hilfe System ist
  95. dahingehend dynamisch das Provider dem eigenen System hinzugefügt und
  96. automatisch ausgeführt werden, und als solches werden die notwendigen Parameter
  97. damit Sie ausgeführt werden können, im Hilfe Schirm vorhanden. Der einfachste Weg um
  98. den Hilfe Schirm zu erhalten ist der folgende:
  99. </para>
  100. <programlisting language="text"><![CDATA[
  101. zf --help
  102. ]]></programlisting>
  103. <para>
  104. Das gibt einen Überblick über die verschiedenen Möglichkeiten des Systems. Manchmal
  105. gibt es engültigere Kommandos die ausgeführt werden können, und um mehr
  106. Informationen über Sie zu erhalten muss man ein spezialisierteres Hilfe Kommando
  107. ausführen. Für die spezialisierte Hilfe muss einfach eines der Elemente des
  108. Kommandos mit einem "=" ersetzt werden. Das sagt dem Hilfe System das man mehr
  109. Informationen darüber will welche Kommandos an Stelle des Fragezeichens stehen
  110. können. Zum Beispiel:
  111. </para>
  112. <programlisting language="text"><![CDATA[
  113. zf ? controller
  114. ]]></programlisting>
  115. <para>
  116. Das obige bedeutet "zeig mir alle 'Aktionen' für den Provider 'controller'"; wärend
  117. das folgende:
  118. </para>
  119. <programlisting language="text"><![CDATA[
  120. zf show ?
  121. ]]></programlisting>
  122. <para>
  123. bedeutet "zeig mit alle Provider welche die 'show' Aktion unterstützen. Das arbeitet
  124. auch wenn man in Optionen geht wie man im folgenden Beispiel sehen kann:
  125. </para>
  126. <programlisting language="text"><![CDATA[
  127. zf show version.? (zeige alle Spezialitäten)
  128. zf show version ? (zeige alle Optionen)
  129. ]]></programlisting>
  130. </sect3>
  131. <sect3 id="zend.tool.usage.cli.general-purpose-commands.manifest">
  132. <title>Manifest</title>
  133. <para>
  134. Das zeigt welche Informationen im Tooling System Manifest sind. Das ist wichtiger
  135. für Entwickler von Providers als für normale Benutzer des Tooling Systems.
  136. </para>
  137. <programlisting language="text"><![CDATA[
  138. zf show manifest
  139. ]]></programlisting>
  140. </sect3>
  141. <!--
  142. <sect3 id="zend.tool.usage.cli.general-purpose-commands.tool-configuration">
  143. <title>Tool Konfiguration</title>
  144. <para>Platzhalter, benötigt Handbuch von @beberli</para>
  145. </sect3>
  146. -->
  147. </sect2>
  148. <sect2 id="zend.tool.usage.cli.project-specific-commands">
  149. <title>Projekt spezifische Kommandos</title>
  150. <sect3 id="zend.tool.usage.cli.project-specific-commands.project">
  151. <title>Project</title>
  152. <para>
  153. The project provider is the first command you might want to run. This will setup the basic
  154. structure of your application. This is required before any of the other providers can
  155. be executed.
  156. </para>
  157. <programlisting language="text"><![CDATA[
  158. zf create project MyProjectName
  159. ]]></programlisting>
  160. <para>
  161. This will create a project in a directory called ./MyProjectName. From this point on,
  162. it is important to note that any subsequent commands on the command line must be issued
  163. from within the project directory you had just created. So, after creation, changing into
  164. that directory is required.
  165. </para>
  166. </sect3>
  167. <sect3 id="zend.tool.usage.cli.project-specific-commands.module">
  168. <title>Project</title>
  169. <para>
  170. The module provider allows for the easy creation of a Zend Framework module. A module
  171. follows the hMVC pattern loosely. When creating modules, it will take the same structure
  172. used at the application/ level, and duplicate it inside of the chosen name for your module,
  173. inside of the "modules" directory of the application/ directory without duplicating the
  174. modules directory itself. For example:
  175. </para>
  176. <programlisting language="text"><![CDATA[
  177. zf create module Blog
  178. ]]></programlisting>
  179. <para>
  180. This will create a module named Blog at application/modules/Blog, and all of the artifacts
  181. that a module will need.
  182. </para>
  183. </sect3>
  184. <sect3 id="zend.tool.usage.cli.project-specific-commands.controller">
  185. <title>Controller</title>
  186. <para>
  187. The controller provider is responsible for creating (mostly) empty controllers as well
  188. as their corresponding view script directories and files. To utilize it to create
  189. an 'Auth' controlller, for example, execute:
  190. </para>
  191. <programlisting language="text"><![CDATA[
  192. zf create controller Auth
  193. ]]></programlisting>
  194. <para>
  195. This will create a controller named Auth, specifically it will create a file at
  196. application/controllers/AuthController.php with the AuthController inside.
  197. If you wish to create a controller for a module, use any of the following:
  198. </para>
  199. <programlisting language="text"><![CDATA[
  200. zf create controller Post 1 Blog
  201. zf create controller Post -m Blog
  202. zf create controller Post --module=Blog
  203. ]]></programlisting>
  204. <para>
  205. Note: In the first command, 1 is the value for the "includeIndexAction" flag.
  206. </para>
  207. </sect3>
  208. <sect3 id="zend.tool.usage.cli.project-specific-commands.action">
  209. <title>Action</title>
  210. <para>
  211. To create an action within an existing controller:
  212. </para>
  213. <programlisting language="text"><![CDATA[
  214. zf create action login Auth
  215. zf create action login -c Auth
  216. zf create action login --controller-name=Auth
  217. ]]></programlisting>
  218. </sect3>
  219. <sect3 id="zend.tool.usage.cli.project-specific-commands.view">
  220. <title>View</title>
  221. <para>
  222. To create a view outside of the normal controller/action creation, you would use
  223. one of the following:
  224. </para>
  225. <programlisting language="text"><![CDATA[
  226. zf create view Auth my-script-name
  227. zf create view -c Auth -a my-script-name
  228. ]]></programlisting>
  229. <para>
  230. This will create a view script in the controller folder of Auth.
  231. </para>
  232. </sect3>
  233. <sect3 id="zend.tool.usage.cli.project-specific-commands.model">
  234. <title>Model</title>
  235. <para>
  236. The model provider is only responsible for creating the proper model files,
  237. with the proper name inside the application folder. For example
  238. </para>
  239. <programlisting language="text"><![CDATA[
  240. zf create model User
  241. ]]></programlisting>
  242. <para>
  243. If you wish to create a model within a specific module:
  244. </para>
  245. <programlisting language="text"><![CDATA[
  246. zf create model Post -m Blog
  247. ]]></programlisting>
  248. <para>
  249. The above will create a 'Post' model inside of the 'Blog' module.
  250. </para>
  251. </sect3>
  252. <sect3 id="zend.tool.usage.cli.project-specific-commands.form">
  253. <title>Form</title>
  254. <para>
  255. The form provider is only responsible for creating the proper form file and
  256. init() method, with the proper name inside the application folder. For example:
  257. </para>
  258. <programlisting language="text"><![CDATA[
  259. zf create form Auth
  260. ]]></programlisting>
  261. <para>
  262. If you wish to create a model within a specific module:
  263. </para>
  264. <programlisting language="text"><![CDATA[
  265. zf create form Comment -m Blog
  266. ]]></programlisting>
  267. <para>
  268. The above will create a 'Comment' form inside of the 'Blog' module.
  269. </para>
  270. </sect3>
  271. <sect3 id="zend.tool.usage.cli.project-specific-commands.database-adapter">
  272. <title>DbAdapter</title>
  273. <para>
  274. To configure a DbAdapter, you will need to provide the information as a url
  275. encoded string. This string needs to be in quotes on the command line.
  276. </para>
  277. <para>
  278. For example, to enter the following information:
  279. <itemizedlist>
  280. <listitem>
  281. <para>adapter: Pdo_Mysql</para>
  282. </listitem>
  283. <listitem>
  284. <para>username: test</para>
  285. </listitem>
  286. <listitem>
  287. <para>password: test</para>
  288. </listitem>
  289. <listitem>
  290. <para>dbname: test </para>
  291. </listitem>
  292. </itemizedlist>
  293. The following will have to be run on the command line:
  294. </para>
  295. <programlisting language="text"><![CDATA[
  296. zf configure dbadapter "adapter=Pdo_Mysql&username=test&password=test&dbname=test"
  297. ]]></programlisting>
  298. <para>
  299. This assumes you wish to store this information inside of the
  300. 'production' space of the application configuration file. The following will
  301. demonstrate an sqlite configuration, in the 'development' section of the
  302. application config file.
  303. </para>
  304. <programlisting language="text"><![CDATA[
  305. zf configure dbadapter "adapter=Pdo_Sqlite&dbname=../data/test.db" development
  306. zf configure dbadapter "adapter=Pdo_Sqlite&dbname=../data/test.db" -s development
  307. ]]></programlisting>
  308. </sect3>
  309. <sect3 id="zend.tool.usage.cli.project-specific-commands.db-table">
  310. <title>DbTable</title>
  311. <para>
  312. The DbTable provider is responsible for creating Zend_Db_Table
  313. model/data access files for your application to consume, with the proper
  314. class name, and in the proper location in the application. The two
  315. important pieces of information are the <emphasis>DbTable name</emphasis>,
  316. and the <emphasis>actual database table name</emphasis>. For example:
  317. </para>
  318. <programlisting language="text"><![CDATA[
  319. zf create dbtable User user
  320. zf create dbtable User -a user
  321. // also accepts a force option to overwrite existing files
  322. zf create dbtable User user -f
  323. zf create dbtable User user --force-override
  324. ]]></programlisting>
  325. <para>
  326. The DbTable provider is also capable of creating the proper files by
  327. scanning the database configured with the above DbAdapter provider.
  328. </para>
  329. <programlisting language="text"><![CDATA[
  330. zf create dbtable.from-database
  331. ]]></programlisting>
  332. <para>
  333. When executing the above, it might make sense to use the pretend / "-p"
  334. flag first so that you can see what would be done, and what tables can
  335. be found in the database.
  336. </para>
  337. <programlisting language="text"><![CDATA[
  338. zf -p create dbtable.from-database
  339. ]]></programlisting>
  340. </sect3>
  341. <sect3 id="zend.tool.usage.cli.project-specific-commands.layout">
  342. <title>Layout</title>
  343. <para>
  344. Currently, the only supported action for layouts is simply to enable them
  345. will setup the proper keys in the application.ini file for the application
  346. resource to work, and create the proper directories and layout.phtml file.
  347. </para>
  348. <programlisting language="text"><![CDATA[
  349. zf enable layout
  350. ]]></programlisting>
  351. </sect3>
  352. </sect2>
  353. <sect2 id="zend.tool.usage.cli.environment-customization">
  354. <title>Environment Customization</title>
  355. <sect3 id="zend.tool.usage.cli.environment-customization.storage-directory">
  356. <title>The Storage Directory</title>
  357. <para>
  358. The storage directory is important so that providers may have a place to find
  359. custom user generated logic that might change the way they behave. One example
  360. can be found below is the placement of a custom project profile file.
  361. </para>
  362. <programlisting language="text"><![CDATA[
  363. zf --setup storage-directory
  364. ]]></programlisting>
  365. </sect3>
  366. <sect3 id="zend.tool.usage.cli.environment-customization.configuration-file">
  367. <title>The Configuration File</title>
  368. <para>
  369. This will create the proper zf.ini file. This <emphasis>should</emphasis>
  370. be run after <code>zf --setup storage-directory</code>. If it is not, it will
  371. be located inside the users home directory. If it is, it will be located inside
  372. the users storage directory.
  373. </para>
  374. <programlisting language="text"><![CDATA[
  375. zf --setup config-file
  376. ]]></programlisting>
  377. </sect3>
  378. <sect3 id="zend.tool.usage.cli.environment-customization.environment-locations">
  379. <title>Environment Locations</title>
  380. <para>
  381. These should be set if you wish to override the default places where zf will
  382. attempt to read their values.
  383. </para>
  384. <itemizedlist>
  385. <listitem>
  386. <para>ZF_HOME</para>
  387. <itemizedlist>
  388. <listitem><para>the directory this tool will look for a home directory</para></listitem>
  389. <listitem><para>directory must exist</para></listitem>
  390. <listitem>
  391. <para>search order:</para>
  392. <itemizedlist>
  393. <listitem><para>ZF_HOME environment variable</para></listitem>
  394. <listitem><para>HOME environment variable</para></listitem>
  395. <listitem><para>then HOMEPATH environment variable</para></listitem>
  396. </itemizedlist>
  397. </listitem>
  398. </itemizedlist>
  399. </listitem>
  400. <listitem>
  401. <para>ZF_STORAGE_DIRECTORY</para>
  402. <itemizedlist>
  403. <listitem><para>where this tool will look for a storage directory</para></listitem>
  404. <listitem><para>directory must exist</para></listitem>
  405. <listitem>
  406. <para>search order:</para>
  407. <itemizedlist>
  408. <listitem><para>ZF_STORAGE_DIRECTORY environment variable</para></listitem>
  409. <listitem><para>$homeDirectory/.zf/ directory</para></listitem>
  410. </itemizedlist>
  411. </listitem>
  412. </itemizedlist>
  413. </listitem>
  414. <listitem>
  415. <para>ZF_CONFIG_FILE</para>
  416. <itemizedlist>
  417. <listitem><para>where this tool will look for a configuration file</para></listitem>
  418. <listitem>
  419. <para>search order:</para>
  420. <itemizedlist>
  421. <listitem><para>ZF_CONFIG_FILE environment variable</para></listitem>
  422. <listitem><para>$homeDirectory/.zf.ini file if it exists</para></listitem>
  423. <listitem><para>$storageDirectory/zf.ini file if it exists</para></listitem>
  424. </itemizedlist>
  425. </listitem>
  426. </itemizedlist>
  427. </listitem>
  428. <listitem>
  429. <para>ZF_INCLUDE_PATH</para>
  430. <itemizedlist>
  431. <listitem><para>set the include_path for this tool to use this value</para></listitem>
  432. <listitem>
  433. <para>original behavior:</para>
  434. <itemizedlist>
  435. <listitem><para>use php's include_path to find ZF</para></listitem>
  436. <listitem><para>use the ZF_INCLUDE_PATH environment variable</para></listitem>
  437. <listitem><para>use the path ../library (relative to zf.php) to find ZF</para></listitem>
  438. </itemizedlist>
  439. </listitem>
  440. </itemizedlist>
  441. </listitem>
  442. <listitem>
  443. <para>ZF_INCLUDE_PATH_PREPEND</para>
  444. <itemizedlist>
  445. <listitem><para>prepend the current php.ini include_path with this value</para></listitem>
  446. </itemizedlist>
  447. </listitem>
  448. </itemizedlist>
  449. </sect3>
  450. </sect2>
  451. </sect1>