In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail what are the basic knowledge points about Zend Framework. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
The details are as follows:
Zend framework is an implementation of the MVC pattern, and to get started quickly, you can almost just look at the Zend_Controller Zend_View section.
1.Zend_Controller part. The most important class is Zend_Controller_Front. The classic code to use it is simple:
$front=Zend_Controller_Front::getInstance (); $front- > setControllerDirectory (". / app/controllers"); $front- > dispatch ()
The point here is that you can't use new to get a Zend_Controller_Front, you can only call the getInstance method to return an instance (my zend_framework uses 1.01). The controllers directory I specified here is under the app folder under the root of the www document. In general, app should not be placed under the document root-- the so-called security issue: if the configuration is not strict, the files in the www document root may be visible to visitors. Generally put it in another directory, for example, at the same level as the document root directory, you can use:
$front- > setControllerDirectory (".. / app/controllers")
There is an extra "." The relative path is used here. You can specify another directory with the full name of the path. For example:
$front- > setControllerDirectory ("E: / server/app/controllers")
This part is included in index. In php. In the correct configuration, any request will be redirected by the rewrite function to this $front, the front-end controller Zend_Controller_Front instance. All authentication and other processing should be processed before dispatch.
The common codes for 2.Zend_View are:
$view=new Zend_View (); Zend_Registry::set ("view". $view)
The directory structure recommended by Zend_Framework is adopted by default. That is, both views and controllers models siblings are in the application directory. There are three sibling directories, scrackers helpers filters, under views. So when you define a Controller, you have to create a new directory under scrackers to store the templates that are subordinate to that Controller. Like a simple one.
Class IndexController extends Zend_Controller_Action {function IndexAction () {}}
You need to create an index directory in it and an index.phtml template in the index directory accordingly. If you build another function addAction () under IndexController, you will have to create a new add.phtml in index. If you have another UserController, you need to have a corresponding user directory under the scr directory pts. These * .phtml files are similar to html files that define how your output is displayed. The simple thing is to leave it blank. But you can't have it, otherwise it will prompt you to say "error" invalid Controller.... This is because the default ErrorController is already registered. The default ErrorController is called when the current end controller cannot find the corresponding controller distribution.
Sometimes we don't want to use the default directory structure or the default phtml type view template. At this point, we can use
$view- > setParam ("noViewRanderer", true)
To cancel the default phtml type directory setting. Use
$view- > setParam ("noErrorHandler", true)
To write in the default ErrorController. Use
$view- > setscrroomptPath (". / app/views")
To set the location of your template. This is useful when using smarty templates.
It can be written as follows:
$view=new Zend_View_Smarty (); $view- > setParam ("noViewRanderer", true); $view- > setParam ("noErrorHandler", true); $view- > setscrroomptPath (". / app/views"); Zend_Registry::set ("view". $view)
When using it, you can get it like this:
$view=Zend_Registry::get ("view")
3. When you first come into contact with model, you can simply understand it as a data object. For those who operate the database, you can directly inherit Zend_Db_Table. This class is encapsulated very well, and it is generally sufficient:
Class data extends Zend_Db_Table {protected $_ name= "data";}
You only need to specify the name of the table, of course, you can not display the specified, then zendf will default to your class name to find the table in the database. Don't forget to specify defaultAdapter for Zend_Db_Table:
$config = new Zend_Config_Ini ('. / application/config.ini', 'general'); $db = Zend_Db::factory ($config- > db- > adapter, $config- > db- > config- > toArray ()); Zend_Db_Table::setDefaultAdapter ($db)
Config.ini is similar to [general]
Db.adapter = PDO_MYSQLdb.config.host = localhostdb.config.username = robdb.config.password = 123456db.config.dbname = zftest this article is about "what are the basic knowledge points of Zend Framework". I hope the above content can be helpful to you so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.