Previous Next

Using Zend_Tool On The Command Line

The CLI, or command line tool (internally known as the console tool), is currently the primary interface for dispatching Zend_Tool requests. With the CLI 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 cmd.exe, console2 and also with the Cygwin project.

Installation

Download And Go

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 same directory as the location of the PHP cli binary.

Installing Via Pear

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.

pear channel-discover pear.zfcampus.org
pear install zfcampus/zf

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

Installing by Hand

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).

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).

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.

General Purpose Commands

Version

This will show the current version number of the copy of Zend Framework the zf.php tool is using.

zf show version

Built-in Help

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:

zf --help

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:

zf ? controller

The above means "show me all 'actions' for the provider 'controller'"; while the following:

zf show ?

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:

zf show version.? (show any specialties)
zf show version ? (show any options)

Manifest

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.

zf show manifest

Project Specific Commands

Project

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.

zf create project MyProjectName

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.

Module

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:

zf create module Blog

This will create a module named Blog at application/modules/Blog, and all of the artifacts that a module will need.

Controller

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:

zf create controller Auth

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:

zf create controller Post 1 Blog
zf create controller Post -m Blog
zf create controller Post --module=Blog

Note: In the first command, 1 is the value for the "includeIndexAction" flag.

Action

To create an action within an existing controller:

zf create action login Auth
zf create action login -c Auth
zf create action login --controller-name=Auth

View

To create a view outside of the normal controller/action creation, you would use one of the following:

zf create view Auth my-script-name
zf create view -c Auth -a my-script-name

This will create a view script in the controller folder of Auth.

Model

The model provider is only responsible for creating the proper model files, with the proper name inside the application folder. For example

zf create model User

If you wish to create a model within a specific module:

zf create model Post -m Blog

The above will create a 'Post' model inside of the 'Blog' module.

Form

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:

zf create form Auth

If you wish to create a model within a specific module:

zf create form Comment -m Blog

The above will create a 'Comment' form inside of the 'Blog' module.

DbAdapter

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.

For example, to enter the following information:

  • adapter: Pdo_Mysql

  • username: test

  • password: test

  • dbname: test

The following will have to be run on the command line:

zf configure dbadapter "adapter=Pdo_Mysql&username=test&password=test&dbname=test"

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.

zf configure dbadapter "adapter=Pdo_Sqlite&dbname=../data/test.db" development
zf configure dbadapter "adapter=Pdo_Sqlite&dbname=../data/test.db" -s development

DbTable

The DbTable provider is responsible for creating Zend_Db_Table 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 DbTable name, and the actual database table name. For example:

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

The DbTable provider is also capable of creating the proper files by scanning the database configured with the above DbAdapter provider.

zf create dbtable.from-database

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.

zf -p create dbtable.from-database

Layout

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.

zf enable layout

Environment Customization

The Storage Directory

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.

zf --setup storage-directory

The Configuration File

This will create the proper zf.ini file. This should be run after zf --setup storage-directory. 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.

zf --setup config-file

Environment Locations

These should be set if you wish to override the default places where zf will attempt to read their values.

  • ZF_HOME

    • the directory this tool will look for a home directory

    • directory must exist

    • search order:

      • ZF_HOME environment variable

      • HOME environment variable

      • then HOMEPATH environment variable

  • ZF_STORAGE_DIRECTORY

    • where this tool will look for a storage directory

    • directory must exist

    • search order:

      • ZF_STORAGE_DIRECTORY environment variable

      • $homeDirectory/.zf/ directory

  • ZF_CONFIG_FILE

    • where this tool will look for a configuration file

    • search order:

      • ZF_CONFIG_FILE environment variable

      • $homeDirectory/.zf.ini file if it exists

      • $storageDirectory/zf.ini file if it exists

  • ZEND_TOOL_INCLUDE_PATH

    • set the include_path for this tool to use this value

    • original behavior:

      • use PHP's include_path to find ZF

      • use the ZEND_TOOL_INCLUDE_PATH environment variable

      • use the path ../library (relative to zf.php) to find ZF

  • ZF_TOOL_INCLUDE_PATH_PREPEND

    • prepend the current php.ini include_path with this value

Previous Next
Introduction au Zend Framework
Présentation
Installation
Apprendre Zend Framework
Démarrez rapidement avec Zend Framework
Zend Framework & Introduction MVC
Créer votre projet
Créer une layout
Créer un modèle et une table en base de données
Créer un formulaire
Félicitations !
Chargement automatique avec Zend Framework
Introduction
Architecture et buts
Utilisation de base de l'autoloader
Auto-chargement de resources
Conclusion
Les plugins dans Zend Framework
Introduction
Utiliser des Plugins
Conclusion
Bien démarrer avec Zend_Layout
Introduction
Utiliser Zend_Layout
Zend_Layout: Conclusions
Bien démarrer avec Zend_View
Introduction
Utilisation de base des Placeholders
Placeholders standards
View Placeholders: Conclusion
Bien comprendre et utiliser les décorateurs Zend Form
Introduction
Les bases des décorateurs
Chainer les décorateurs
Rendu individuel des décorateurs
Créer et rendre des éléments composites
Conclusion
Bien démarrer avec Zend_Session, Zend_Auth, et Zend_Acl
Fabrique une application Multi-Utilisateurs avec Zend Framework
Gérer les sessions dans ZF
Authentification d'utilisateurs dans Zend Framework
Fabriquer un système de gestion d'autorisations avec Zend Framework
Bien démarrer avec Zend_Search_Lucene
Introduction à Zend_Search_Lucene
Structure d'index Lucene
Ouverture et création d'index
Indexation
Recherche
Requêtes supportées
Pagination de résultat de recherche
Bien démarrer avec Zend_Paginator
Introduction
Exemples simples
Contrôles de la pagination et styles de défilement
Assembler le tout
Guide de référence Zend Framework
Zend_Acl
Introduction
Affiner les Contrôles d'Accès
Utilisation avancée
Zend_Amf
Introduction
Zend_Amf_Server
Zend_Application
Introduction
Zend_Application démarrage rapide
Théorie générale
Exemples
Fonctionnalités principales
Plugins de ressources disponibles
Zend_Auth
Introduction
Authentification avec une table de base de données
Authentification "Digest"
Adaptateur d'authentification HTTP
LDAP Authentication
Authentification OpenID
Zend_Barcode
Introduction
Création de code-barres avec la classe Zend_Barcode
Zend_Barcode Objects
Zend_Barcode Renderers
Zend_Cache
Introduction
Aspect théorique
Les frontends Zend_Cache
Les backends Zend_Cache
Le gestionnaire de Cache
Zend_Captcha
Introduction
Opération Captcha
Adaptateurs CAPTCHA
SimpleCloud API: Zend_Cloud
Document Service Introduction
Queue Service Introduction
StorageService Introduction
Zend_CodeGenerator
Introduction
Exemples Zend_CodeGenerator
Zend_CodeGenerator Réference
Zend_Config
Introduction
Aspect théorique
Zend_Config_Ini
Zend_Config_Json
Zend_Config_Xml
Zend_Config_Yaml
Zend_Config_Writer
Zend_Config_Writer
Zend_Console_Getopt
Introduction
Déclarer les règles Getopt
Extraire les options et les arguments
Configurer Zend_Console_Getopt
Zend_Controller
Zend_Controller - Démarrage rapide
Fondations de Zend_Controller
Le contrôleur frontal (Front Controller)
L'objet Requête
Routeur Standard
Le distributeur
Contrôleurs d'action
Aides d'action (Helper)
Objet de réponse
Plugins
Utilisation de conventions de dossiers modulaires
Exceptions avec MVC
Zend_Currency
Introduction à Zend_Currency
Utiliser Zend_Currency
Options des monnaies
Qu'est ce qui définit une monnaie?
Où est le symbole monnétaire?
A quoi ressemble une monnaie?
Travailler avec les valeurs des monnaies (les montants)
Calculs avec les monnaies
Echanger (convertir) des monnaies
Informations complémentaires pour Zend_Currency
Zend_Date
Introduction
Aspect théorique
Méthodes de base
Zend_Date API Overview
Créer des dates
Constants for General Date Functions
Exemples concrets
Zend_Db
Zend_Db_Adapter
Zend_Db_Statement
Zend_Db_Profiler
Zend_Db_Select
Zend_Db_Table
Zend_Db_Table_Row
Zend_Db_Table_Rowset
Relations Zend_Db_Table
Zend_Db_Table_Definition
Zend_Debug
Afficher des informations
Zend_Dojo
Introduction
Zend_Dojo_Data: dojo.data Envelopes
Les aides de vues Dojo
Les éléments de formulaire et les décorateurs Dojo
Zend_Dojo build layer support
Zend_Dom
Introduction
Zend_Dom_Query
Zend_Exception
Utiliser les exceptions
Utilisation classique
Exceptions précédentes
Zend_Feed
Introduction
Importer des flux
Obtenir des flux à partir de pages Web
Consommer un flux RSS
Consommer un flux Atom
Consommer une entrée Atom particulière
Modifier la structure du flux ou des entrées
Classes personnalisées pour les flux et entrées
Zend_Feed_Reader
Zend_Feed_Writer
Zend_Feed_Pubsubhubbub
Zend_File
Zend_File_Transfer
Validateurs pour Zend_File_Transfer
Filtres pour Zend_File_Transfer
Zend_Filter
Introduction
Classes de filtre standards
Chaînes de filtrage
Écriture de filtres
Zend_Filter_Input
Zend_Filter_Inflector
Zend_Form
Zend_Form
Zend_Form démarrage rapide
Creating Form Elements Using Zend_Form_Element
Creating Forms Using Zend_Form
Créer un visuel personnalisé en utilisant Zend_Form_Decorator
Les éléments standards fournis avec Zend Framework
Décorateurs standards fournis avec Zend Framework
Internationaliser un formulaire Zend_Form
Advanced Zend_Form Usage
Zend_Gdata
Introduction
Authentification par procédé AuthSub
Using the Book Search Data API
Authentification avec ClientLogin
Using Google Calendar
Using Google Documents List Data API
Using Google Health
Using Google Spreadsheets
Using Google Apps Provisioning
Using Google Base
Utilisation des albums Web Picasa
Using the YouTube Data API
Attraper les exceptions Gdata
Zend_Http
Introduction
Zend_Http_Client - Utilisation avancée
Zend_Http_Client - Adaptateurs de connexion
Zend_Http_Cookie and Zend_Http_CookieJar
Zend_Http_Response
Zend_Http_UserAgent
The UserAgent Device Interface
The UserAgent Features Adapter
The WURFL UserAgent Features Adapter
The DeviceAtlas UserAgent Features Adapter
The TeraWurfl UserAgent Features Adapter
The UserAgent Storage Interface
The Session UserAgent Storage Adapter
Zend_InfoCard
Introduction
Zend_Json
Introduction
Utilisation de base
Utilisation avancée de Zend_Json
XML to JSON conversion
Zend_Json_Server - JSON-RPC server
Zend_Layout
Introduction
Zend_Layout - Démarrage rapide
Zend_Layout options de configuration
Zend_Layout, utilisation avancée
Zend_Ldap
Introduction
API overview
Scénarios d'utilisation
Outils
Accès à l'arbre LDAP de manière orientée objet avec Zend_Ldap_Node
Récupérer des informations depuis un serveur LDAP
Serialiser des données LDAP depuis/vers LDIF
Zend_Loader
Charger les fichiers et les classes dynamiquement
L'autoloader
Autoloaders de ressources
Chargeur de Plugins
Zend_Locale
Introduction
Using Zend_Locale
Normalization and Localization
Working with Dates and Times
Supported locales
Zend_Log
Présentation
Rédacteurs (Writers)
Formateurs (mise en forme)
Filtres
Utiliser la fabrique pour créer des logs
Zend_Mail
Introduction
Envoyer des courriels en utilisant SMTP
Envoyer plusieurs courriels par connexion SMTP
Utiliser différents transports
Courriel HTML
Fichiers joints
Ajouter des destinataires
Contrôler les limites MIME
En-têtes additionnels
Jeux de caractères
Encodage
Authentification SMTP
Sécuriser les transports SMTP
Lire des courriels
Zend_Markup
Introduction
Guide de démarrage avec Zend_Markup
Analyseurs Zend_Markup (parsers)
Moteurs de rendu Zend_Markup
Zend_Measure
Introduction
Création d'une mesure
Récupérer des mesures
Manipuler des mesures
Types de mesures
Zend_Memory
Présentation
Manager de mémoire
Objet mémoire
Zend_Mime
Zend_Mime
Zend_Mime_Message
Zend_Mime_Part
Zend_Navigation
Introduction
Pages
Containers
Zend_Oauth
Introduction to OAuth
Zend_OpenId
Introduction
Zend_OpenId_Consumer Basics
Zend_OpenId_Provider
Zend_Paginator
Introduction
Utilisation
Configuration
Utilisation avancée
Zend_Pdf
Introduction
Créer et charger des documents PDF
Sauvegarder les changement dans un document PDF
Les pages d'un document
Dessiner
Interactive Features
Informations du document et métadonnées
Exemple d'utilisation du module Zend_Pdf
Zend_ProgressBar
Zend_ProgressBar
Zend_Queue
Introduction
Example usage
Framework
Adapters
Customizing Zend_Queue
Stomp
Zend_Reflection
Introduction
Zend_Reflection Exemples
Réference de Zend_Reflection
Zend_Registry
Utiliser le registre
Zend_Rest
Introduction
Zend_Rest_Client
Zend_Rest_Server
Zend_Search_Lucene
Vue d'ensemble
Créer des index
Chercher dans un index
Langage de requêtes
API de construction de requêtes
Jeu de caractères
Extensibilité
Agir avec Lucene Java
Avancé
Bonnes pratiques
Zend_Serializer
Introduction
Zend_Serializer_Adapter
Zend_Server
Introduction
Zend_Server_Reflection
Zend_Service
Introduction
Zend_Service_Akismet
Zend_Service_Amazon
Zend_Service_Amazon_Ec2
Zend_Service_Amazon_Ec2: Instances
Zend_Service_Amazon_Ec2: Windows Instances
Zend_Service_Amazon_Ec2: Reserved Instances
Zend_Service_Amazon_Ec2: CloudWatch Monitoring
Zend_Service_Amazon_Ec2: Amazon Machine Images (AMI)
Zend_Service_Amazon_Ec2: Elastic Block Storage (EBS)
Zend_Service_Amazon_Ec2: Elastic IP Addresses
Zend_Service_Amazon_Ec2: Keypairs
Zend_Service_Amazon_Ec2: Regions and Availability Zones
Zend_Service_Amazon_Ec2: Security Groups
Zend_Service_Amazon_S3
Zend_Service_Amazon_Sqs
Zend_Service_Audioscrobbler
Zend_Service_Delicious
Zend_Service_DeveloperGarden
Zend_Service_Ebay
Zend_Service_Ebay_Finding
Zend_Service_Flickr
Zend_Service_LiveDocx
Zend_Service_Nirvanix
Zend_Service_ReCaptcha
Zend_Service_ShortUrl
Zend_Service_Simpy
Zend_Service_SlideShare
Zend_Service_StrikeIron
Zend_Service_StrikeIron: Bundled Services
Zend_Service_StrikeIron: Advanced Uses
Zend_Service_Technorati
Zend_Service_Twitter
Zend_Service_WindowsAzure
Zend_Service_WindowsAzure_Storage_Blob
Zend_Service_WindowsAzure_Diagnostics_Manager
Zend_Service_WindowsAzure_Storage_Queue
Zend_Service_WindowsAzure_Storage_Table
Zend_Service_Yahoo
Zend_Session
Introduction
Usage basique
Utilisation avancée
Gestion générale de la session
Zend_Session_SaveHandler_DbTable
Zend_Soap
Zend_Soap_Server
Zend_Soap_Client
WSDL
Auto découverte
Zend_Tag
Introduction
Zend_Tag_Cloud
Zend_Test
Introduction
Zend_Test_PHPUnit
Zend_Test_PHPUnit_Db
Zend_Text
Zend_Text_Figlet
Zend_Text_Table
Zend_TimeSync
Introduction
Utiliser Zend_TimeSync
Zend_Tool
Using Zend_Tool On The Command Line
Extending Zend_Tool
Zend_Tool_Framework
Introduction
Using the CLI Tool
Architecture
Creating Providers to use with Zend_Tool_Framework
Shipped System Providers
Extending and Configuring Zend_Tool_Framework
Zend_Tool_Project
Introduction
Créer un projet
Fournisseurs de Zend_Tool_Project
Rouages internes de Zend_Tool_Project
Zend_Translate
Introduction
Adaptateurs pour Zend_Translate
Utiliser les adaptateurs de traduction
Creating source files
Additional features for translation
Notation des pluriels pour Translation
Zend_Uri
Zend_Uri
Zend_Validate
Introduction
Classes de validation standard
Chaînes de validation
Écrire des validateurs
Messages de validation
Zend_Version
Lire la version de Zend Framework
Zend_View
Introduction
Scripts de contrôleur
Scripts de vue
Aides de vue
Zend_View_Abstract
Zend_Wildfire
Zend_Wildfire
Zend_XmlRpc
Introduction
Zend_XmlRpc_Client
Zend_XmlRpc_Server
ZendX_Console_Process_Unix
ZendX_Console_Process_Unix
ZendX_JQuery
Introduction
ZendX_JQuery View Helpers
ZendX_JQuery Form Elements and Decorators
Configuration système requise par Zend Framework
Introduction
Notes de migration de Zend Framework
Zend Framework 1.10
Zend Framework 1.9
Zend Framework 1.8
Zend Framework 1.7
Zend Framework 1.6
Zend Framework 1.5
Zend Framework 1.0
Zend Framework 0.9
Zend Framework 0.8
Zend Framework 0.6
Convention de codage PHP de Zend Framework
Vue d'ensemble
Formatage des fichiers PHP
Conventions de nommage
Style de codage
Recommandation sur la documentation de Zend Framework
Présentation
Format des fichiers de documentation
Recommendations
Recommended Project Structure for Zend Framework MVC Applications
Overview
Recommended Project Directory Structure
Module Structure
Rewrite Configuration Guide
Guide de performance Zend Framework
Introduction
Chargement des classes
Performance de Zend_Db
Internationalisation (i18n) and Localisation (l10n)
View Rendering
Informations de copyright