Using Zend_Tool
Zend Framework still goes the way
First, we need to download the Zend Framework from the developers site, or use the SVN repository (from all this stuff we need the bin folder and library / Zend , the rest is not needed yet):
~ $ 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 are true Linux-linux and often create projects on ZF, then upload the zf.sh file to / usr / bin (or any other path where the system can find it), and the Zend folder to where you include include_path for PHP (run php -i | grep include_path command)
We should get the following directory structure:
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 : the utility was tested under Linux, it is likely that it will work under Windows as well (use zf.bat)
After that, we should have created a project, and going to the page you should see something similar to the picture at the very beginning of the article. The directory structure will look like this:
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 a controller and actions:
# create a
user controller and two actions ~ $ ./bin/zf.sh create controller users
~ $ ./bin/zf.sh create action login users
~ $ ./bin/zf.sh create action logout users
We look at the result (UsersController.php file):
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
}
}
An almost empty view script will be created for each action:
View script for controller users and script / action name login
Note : If the public folder is not root, then add the “RewriteBase / public /” rule after “RewriteEngine On” to the file “/public/.htaccess”
In addition to this functionality, there are still the following "features":
- Creating a class for unit tests, turning them on / off - the test provider is not recognized by the utility
- Creating a view - swears and does not create anything; fixing a mistake in a class entails even more errors
At TODO, developers have:
- Model generator - I would like to see the organization of the “correct” model taking into account the latest changes in the framework
- Form generator - interestingly, there should be a connection with the model, I think it will be tasty
Useful articles:
- Zend_Tool_Project Documentation
- Zend_Application Quick Start
- Using Zend_Tool to start up your ZF Project
- Zend_Tool for the Developer
- Zend_Tool for the Developer. Part 2
- Zend_Tool and ZF 1.8
Blog Post Link: Using Zend_Tool