Here, default is the default module directory name, and controllers is the controller Directory. if the default module directory is not set above, modify it here. Note: the class name of the non-default Module controller is written as Admin_IndexController.
1. quickly create a Zend Framework project
Method 1: Use zendStudio to quickly create a zendFramewok project
As shown in: select new-> zendFramework Project
The file structure of a zF project is as follows:
Method 2: Use the command line in windows
...... This manual is very troublesome. I don't want to write it either.
Method 3: Use the command line in linux
...... Reference Manual
2. configure multiple modules
Add multi-module support below. generally, a website has two modules, foreground and background management (or more ).
There are many methods to configure multiple modules. here I will record one of my frequently used methods.
Create a folder named modules in the application directory and place the module directory. If you want to download and create two modules, default and admin, you only need to create the default and admin directories under the modules directory, and set the controllers, models, cut the views folder to these two directories. Shows the file structure of the current application directory:
Modify the application. ini file in the configs directory under the application directory and delete the following line:
Resources. frontController. controllerDirectory = APPLICATION_PATH "/controllers"
Add
Resources. frontController. controllerDirectory. default = APPLICATION_PATH "/modules/default/controllers"
Resources. frontController. controllerDirectory. admin = APPLICATION_PATH "/modules/admin/controllers"
Resources. FrontController. moduleDirectory = APPLICATION_PATH "/modules"
Resources. FrontController. moduleControllerDirectoryName = "controllers"
Resources. FrontController. defaultModule = "default"
Here, default is the default module directory name, and controllers is the controller Directory. if the default module directory is not set above, modify it here.
Note: the class name of the non-default Module controller is written as Admin_IndexController.
3. layout
Create the following directory file in the application folder:
Add in application. ini
Resources. layout. layout = "default"
Resources. layout. layoutPath = APPLICATION_PATH "/layouts/default"
You can use $ this-> _ helper-> layout ()-> setLayout ('default2') in action, and use other layout la s.
The content in default. phtml is as follows:
HeadMeta ()?>
HeadTitle ()?>
HeadLink ()?>
HeadStyle ()?>
HeadScript ()?>
Qian tai mo ban yi
Layout ()-> content?>
We can write this in Action.
$ This-> view-> headLink ()-> appendStylesheet ('/css/site/photo.css ');
$ This-> view-> headMeta ()-> appendName ('author', 'dxk ')
-> AppendName ('keyword', 'Du Xiaokong, dxk ');
$ This-> view-> headScript ()-> appendFile ("/js/site/diary. js ");
We can write this in the view.
$ This-> headStyle ()-> captureStart ();
?>
# Content {border-bottom: 1px solid # BBB; background: # FFF ;}
......
$ This-> headStyle ()-> captureEnd ();
?>
$ This-> headScript ()-> captureStart ();
?>
Var loginName = document. getElementById ("loginName ");
......
$ This-> headScript ()-> captureEnd ();