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