問題描述
我的問題很簡(jiǎn)單:
如何添加 API 和/或第 3 方庫(kù)到我的 ZendFramework以某種方式應(yīng)用它可以在一個(gè)控制器
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
推薦答案
這是一篇詳細(xì)介紹如何實(shí)現(xiàn)此目標(biāo)的博客文章:http://blog.keppens.biz/2009/05/add-your-own-library-to-your-new-zend.html
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
或者,如果您不想調(diào)整 application.ini 文件,您可以通過 Bootstrap 類來完成.將此函數(shù)添加到 Bootstrap:
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_');
}
然后在library"文件夾中,添加一個(gè)名為MyCode"的文件夾.該文件夾應(yīng)該與Zend"文件夾平行.當(dāng)然,您應(yīng)該更改MyCode"以反映您要添加的庫(kù)的名稱.
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.
我應(yīng)該注意,通過使用上述方法,我假設(shè)代碼使用 PEAR 命名方案(就像 ZF).
I should note that by using the above method, I'm assuming the code uses the PEAR naming scheme (just like ZF).
這篇關(guān)于將 3rd 方庫(kù)添加到 ZendFramework的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!