在哪个文件夹中放置我在 Kohana 3.1 框架中扩展的类?
我是 kohana php 框架的新手。在kohana 3.1的modules文件夹中,有许多扩展现有类的空文件。我应该在那些空文件中编写代码吗? 如果是,我需要对引导程序进行任何更改吗? 如果没有,我应该把这些文件放在哪里?它们应该位于应用程序目录内的子文件夹中还是模块目录内? 我必须将哪些文件从模块复制到应用程序?
I am new to the kohana php framework. In the modules folder in kohana 3.1, there are many empty files extending the existing classes. Should I write my code in those empty files?
If yes, do I have to make any changes in bootstrap?
If not, where should I place these files? Should they be in a subfolder inside the Application directory or inside the modules directory?
Which all files will I have to copy from the modules to application?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您看到的那些空文件是为该类创建的别名。一个例子是 Cookie 类,声明如下:
它只是您引用真实类的另一种方式,在本例中为
Kohana_Cookie
,而无需键入所有内容。因此,当您使用诸如 Cookie::salt($name, $value) 之类的内容时,您实际上只是在使用 Kohana_Cookie::salt($name, $value) 。
如果您想扩展一个类,您可以将文件放入您的 application/classes 文件夹中并从那里开始。
Those empty files you see are aliases created for the class. An example would be the Cookie class, declared as so:
It's just another way for you to refer to the real class, in this case
Kohana_Cookie
, without having to type all that out.So when you use something like
Cookie::salt($name, $value)
you're really just usingKohana_Cookie::salt($name, $value)
.If you want to extend a class, you can drop the files into your application/classes folder and go from there.
查看文档 http://kohanaframework.org/3.1/guide
特别是: http://kohanaframework.org/3.1/guide/kohana/files
你可以扩展文件夹中的类:application/classes/..或modules//classes/..
check out the docs at http://kohanaframework.org/3.1/guide
especially: http://kohanaframework.org/3.1/guide/kohana/files
you can extend classes in the folder: application/classes/.. or modules//classes/..