ZendFramework project construction and multi-module configuration

Source: Internet
Author: User
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 ();

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.