Friday, 9 January 2015

Zend Comand line

With the Zend comand line it is easy to create project.Go to your command prompt in windows and type zf  you will see a details list of info if your Zend command prompt is working. As we have set our command line interface for zend simply go to your project directory and type

Creating project

zf create project hellowrold
and Zend will create necessary files and directories for your project.

zend command line is easy to use to create controller, views and models in one line.
database connection is easily set up using commands.
these can also be done manually but we all want things to be done fast and accurate.

Controller with Cmd

go to your newly created project directory and type;
 zf create controller {name of controller}  like
zf create controller users
 and zend will add a controller with the default indexAction()  to it. Along with the the controller necessary Views for the Action is also added to the project.

Action inside controller

 in zend every controller has actions that contains the logic of the project. to create an action type
zf create action {name of action} {name of controller }  like;
zf create action role users
 and zend will add  roleAction() to the controller along with that the role.php file will also be added to the view directory of the project.

Model with cmd

data logic goes into models. To create model type;
zf create model {model name}
zf create model user
 this will create a file user.php into model directory. 

Database connection with cmd

for database connection type 
zf configur dbadapter "adapter=pdo_mysql&username={your username default is root mostly}&password={your password}&dbname={your database name}" like
zf configure dbadapter "adapter = pdo_mysql&username=root&passworld=&dbname=test"
and zend cmd will add necessary lines to your index.php file inside public directory

zend forms


zend has also commands for Forms 
type 
zf create form {name of the form}
zf create form users
and form will be added to the form directory inside the Application directory.
the form directory is not present but when you type the form command it will automatically add form folder to the project


No comments:

Post a Comment