Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
232 views
in Technique[技术] by (71.8m points)

bootstrapping - How to indicate zend framework where my custom classes are

I have a folder with custom classes in a ZF 1.10 application. The folder is located in /library. How can I tell ZF where they are? Both application.ini and index.php set the path to the library but then ZF can't find the files.

Thank you

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

We often come across a problem of writing our own custom functions or classes and where to place them.

So to add custom class (or custom library) one can use zend framework's autoloader namespaces.

Add the below line in application.ini file

autoloaderNamespaces.custom = "Custom_"

OR

autoloaderNamespaces[] = "Custom_"

All the custom classes will be kept under library directory. Create a folder name 'Custom' (which is defined in application.ini) in the library directory.

Classes will be prefixed with 'Custom_' at declaration in the file (e.g. Custom_Test)

Now we can use this class as $test = new Custom_Test(), in our application.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...