3

my question is simple:

How do I add an API and/or 3rd party library to my ZendFramework application in a way which makes it possible to access it in a controller

Charles
  • 50,943
  • 13
  • 104
  • 142
Julius F
  • 3,434
  • 4
  • 29
  • 44
  • 1
    http://209.85.135.132/search?q=cache:AzybkKx45UQJ:mirmodynamics.com/post/2007/10/16/How-I-use-the-Zend-Framework+add+on+3rd+party+library+to+my+Zend+Framework&cd=3&hl=de&ct=clnk – powtac Oct 14 '09 at 15:04
  • @powtac, thank you. But by the way why didn't you posted it as an answer? – Julius F Oct 21 '09 at 19:04

1 Answers1

6

Here is a blog post detailing how to achieve this: http://blog.keppens.biz/2009/05/add-your-own-library-to-your-new-zend.html

Alternatively, if you don't want to tweak the application.ini file, you can do it through your Bootstrap class. Add this function to Bootstrap:

 protected function _initAutoload() {
    $loader = Zend_Loader_Autoloader::getInstance();
    $loader->registerNamespace('MyCode_');
}

Then in the "library" folder, you would add a folder called "MyCode". This folder should be parallel to the "Zend" folder. Naturally you should change "MyCode" to reflect the name of the library you're adding.

I should note that by using the above method, I'm assuming the code uses the PEAR naming scheme (just like ZF).

Steven Mercatante
  • 24,757
  • 9
  • 65
  • 109
  • What is the "PEAR" naming scheme? http://bit.ly/2sskY5 I did not get the right meaning. Is that: PACKAGENAME::CLASSNAME the convention? That assumes, that i have to add MYPACKAGE:: to the namespace instead of MYPACKAGE_ right? – Julius F Oct 14 '09 at 17:59