设为首页 收藏本站
查看: 508|回复: 0

[经验分享] PHP and Zend Framework

[复制链接]

尚未签到

发表于 2017-3-27 08:26:50 | 显示全部楼层 |阅读模式
The Zend framework's controller,Zend_controller is designed to support websites with clean urls.To achieve this, all requests need

to go through a single index.php file known as the bootstrapper. This provides us with a central point for all pages of the application

and ensures that the environment is set up correctly for running the application. The Zend Framework is designed such that its files

must be on the include path. We also place our models directory on the include path so that we can easily load our model classed

later. To kick off we have to include the files Zend.php to gives us access to the Zend class which has the required static functions to

enable us to load any other Zend Framework class. The front controller uses a router class to map the requested url to the correct

php function to be used for displaying the page. In order for the router to operate, it needs to work out wich part of the url is the path

to our index.php so that ir can look at the url elements after that points. The Zend Framework's controller reserves a special action

called index as a default action. Remember that the model is the part that deals with the application's core purpose and hence deals

with the database. We will make use of the Zend Framework class Zend_Db_Table which is used to find,insert,update and delete

rows from a database table. To use Zend_Db_Table,we need to tell it which databse to use along with a username and password.

The Zend Framework provides Zend_config to provide flexible object oriented access to configuration files. At the moment, the

configuration file can be a php array ,an ini file or an xml file. Zend_Db_Table is an abstract class .

Filters and Validators can be added to these elements that we have created. There are various ways of adding validators. The view

can be thought of as a templating system. Like a templating system, it allows you to keep all of your display logic separate from your

business logic. In Zend Framework, the view is represented by Zend_View. In most cases, the view is instantiated automatically by

the controller and we access it with $this->view. The view script is what actually contains the display logic necessary to output the

data prepared by your controller action and or your model. The first thing that the view will do upon render() is find the proper script.

The view looks at the controller name,the action name and mergers that with the location of the scripts to create a uri for the view

script. Zend Framework uses the Zend_Db class to connect to a database. Zend-Db and its related classes give you a PDO-like

interface to talk to your database. you have your adapter and you need to fetch some data. Plugins are for when you want to do

something on every request,regardless of the controller,without any interaction with the controller. Plugins require only that you

register the plugin with the front controller.Then the code it encapsulates will be executed. All the code in Plugins in encapsulated in

either the preDispatch() method or the postDispatch() method. Helpers are for when you want shared functionality that you want to

use selectively within controllers and for which you need some introspection or coupling with the controller. Helpers also allow you to

insert functionality before or after any action. As with plugins,helpers have preDispatch() and postDispatch() methods that if exist will

be called automatically. However,helpers also have a direct() method. direct() is called if you make a call directly to the helper.

As with everything in the Zend Framework,action helpers have a default place on the file system. There are several different levels of

model implementation that can be found in applications. The process of verifying logged in status or not is called authentication or

auth.Determing whether a user has specific rights and acting upon those rights is called access control.  Zend_Auth can be a

complicated beast as it allows you to define your own authentication methods using custom adapters. Natively,Zend Framework

comes with three adapters that you can use

,Zend_Auth_Adapter_Dbtable,Zend_Auth_Adapter_Digest,Zend_Auth_Adapter_Http.By extending the

Zend_Auth_Adapter_Interface you can build  your own custom adapters to authenticate against any backend service you choose.

While different adapters may have vastly different options and parameters,they all have one thing in common.,they all return a

Zend_Auth_Result when authenticate() is called.  The nice thing about Zend_Layout is that is accomplishes this task. Zend_Layout is

broken up into the main layout controller as well as a lot of little helpers.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-355852-1-1.html 上篇帖子: 为什么会造成PHP人才奇缺? 下篇帖子: 初学php——基础语法
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表