Using Zend_Tool
Zend Framework has is on the way
To start, we need download Zend Framework from the developer's site, or use SVN repository (all this stuff we need a folder bin and library/Zend, the rest until needed):
~$ svn co http://framework.zend.com/svn/framework/standard/trunk/bin/ ./bin
~$ svn co http://framework.zend.com/svn/framework/standard/trunk/library/Zend ./library/Zend
note: if You true-linuxoid and often create projects on ZF — cast file zf.sh in /usr/bin (or any other path where the system will be able to find it), and the Zend folder where You have spelled out the include_path for PHP (run php -i |grep include_path)
We should get the following directory structure:
the
htdocs |-- bin | |-- zf.bat | |-- zf.php | `-- zf.sh `-- library `-- Zend
Now open the console go to the htdocs directory and type:
# don't forget chmod a+x ./bin/zf.sh
~$ ./bin/zf.sh create project ./
note utility has been tested under Linux, there is a possibility that under Windows will work too (use zf.bat)
After that we should be created by the project, and go to the page You should see something similar to the picture in the beginning of the article. The directory structure will look like the following:
the
htdocs |-- application | |-- Bootstrap.php | |-- configs | | `-- application.ini | |-- controllers | | |-- ErrorController.php | | `-- IndexController.php | |-- models | `-- views | |-- helpers | `-- scripts | |-- error | | `-- error.phtml | `-- index | `-- index.phtml |-- library |-- public | `-- index.php `-- tests |-- application | `-- bootstrap.php |-- library | `-- bootstrap.php `-- phpunit.xml
Go ahead — create controller and action:
# create a users controller and two action
~$ ./bin/zf.sh create controller users
~$ ./bin/zf.sh create action login users
~$ ./bin/zf.sh create action logout users
Look at the result (file UsersController.php):
<?php
class UsersController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
// action body
}
public function loginAction()
{
// action body
}
public function logoutAction()
{
// action body
}
}
For each action and will be created virtually empty view script:
<br /><br /><center>View script for controller <b>users</b> and script/action name <b>, login</b></center>
note: If the public folder is not a root, then add the file "/public/.htaccess" rule "RewriteBase /public/" after "RewriteEngine On"
In addition to this functionality there is still the following "features":
the
-
the
- create a class for unit tests, enable/disable the add provider test is not recognized by the utility the
- Create view — swears and creates nothing, the error correction in the classroom entails more errors
In the developers TODO:
the
-
the
- Generator models — I would like to look at the organization of the "right" model taking into account the recent changes in the framework the
- form Generator — interesting, there must be a connection with the model, I think would be delicious
Useful articles:
the
-
the
- Documentation on Zend_Tool_Project the
- Zend_Application Quick Start the
- Using Zend_Tool to start up your ZF Project the
- Zend_Tool for the Developer the
- Zend_Tool for the Developer. Part 2 the
- Zend_Tool and ZF 1.8
Link to blog post: Using Zend_Tool