简体   繁体   English

使用正确的命名约定访问Zend中的自定义库

[英]accessing a custom library in Zend with proper naming conventions

Him Can anyone tell me how can I access the library in ZEND framework and what is the proper naming convention for libraries in ZEND. 谁能告诉我如何在ZEND框架中访问库,以及ZEND中库的正确命名约定是什么。 I have the following struture 我有以下结构


--application
--docs
--library
    --myLibrary.php (class name is also same)
--public

How can I access this library in my model? 如何在模型中访问此库?

The best way is to create your own library directory: 最好的方法是创建自己的库目录:

library
    My
        Library.php
    Zend

Add this to ypur index.php: 将此添加到ypur index.php:

Zend_Loader_Autoloader::getInstance()->registerNamespace('My_');

And use this class: 并使用此类:

$obj = new My_Library();

If your library is really a single class called myLibrary stored in library/myLibrary.php , then you should be able to add the following to your application/configs/applicatiom.ini file: 如果您的库确实是一个存储在library/myLibrary.php名为myLibrary类,那么您应该能够将以下内容添加到application/configs/applicatiom.ini文件中:

autoloadernamespaces[] = "myLibrary"

Then you should be able to instantiate a myLibrary object using: 然后,您应该能够使用以下方法实例化myLibrary对象:

$lib = new myLibrary();

好吧,如果您的library文件夹位于包含路径上,那么您可以直接使用myLibrary

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM