accessing a custom library in Zend with proper naming conventions
-
09-06-2021 - |
문제
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. 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?
해결책
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:
autoloadernamespaces[] = "myLibrary"
Then you should be able to instantiate a myLibrary
object using:
$lib = new myLibrary();
다른 팁
The best way is to create your own library directory:
library
My
Library.php
Zend
Add this to ypur index.php:
Zend_Loader_Autoloader::getInstance()->registerNamespace('My_');
And use this class:
$obj = new My_Library();
Well if your library
folder is on the include path then you can use myLibrary
directly.
제휴하지 않습니다 StackOverflow