如何在 Zend 框架中添加新类和自动加载 [英] How to add new class and autoload in zend framework

查看:26
本文介绍了如何在 Zend 框架中添加新类和自动加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Zend 框架的新手并且第一次使用它.我正在寻找可以在很短的时间内阅读的简单的基本教程.如果我想在 Zend 库中添加新类,我也坚持.当我制作任何新控制器时,它也应该自动加载.

I am new on Zend framework and using first time it. I am looking for simple basic tutorials which I can read in very short time. I also stuck on if I want to add new class in Zend library. And it should also auto load when I make any new controller.

如果您有意见,请发表您的意见.

Please give your opinions if you have.

问候,

推荐答案

这对我有帮助 一开始:

This helped me At the beginning:

http://www.zendcasts.com/

http://devzone.zend.com/search/results?q=autoload(只是搜索)

自动加载您的课程,这是我的方式:

As autoload your class, This is the my way:

在库中创建文件夹我的"/在其中创建文件夹 'Utils' 和 Utils 文件 'Utils.php' 所以路径是 library/My/Utils/Utils.php

Create folder 'My' into library/ in it create folder 'Utils' and in Utils file 'Utils.php' so the path is library/My/Utils/Utils.php

对于这个路径你必须调用类:class My_Utils_Utils{ ... }

For this path You must call class: class My_Utils_Utils{ ... }

并在 configs/application.ini 中放入

and in configs/application.ini Put

appnamespace = "应用程序"

appnamespace = "Application"

autoloaderNamespaces.my = "My_"

autoloaderNamespaces.my = "My_"

然后你可以使用命名空间 My_ 和类 My_Utils_Utils

Then you can use namespace My_ and class My_Utils_Utils

在控制器中:$test = new My_Utils_Utils();

In controller: $test = new My_Utils_Utils();

这篇关于如何在 Zend 框架中添加新类和自动加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆