問題描述
我的問題很簡單:
如何添加 API 和/或第 3 方庫到我的 ZendFramework以某種方式應用它可以在一個控制器
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
推薦答案
這是一篇詳細介紹如何實現此目標的博客文章: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
或者,如果您不想調整 application.ini 文件,您可以通過 Bootstrap 類來完成.將此函數添加到 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"文件夾中,添加一個名為MyCode"的文件夾.該文件夾應該與Zend"文件夾平行.當然,您應該更改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.
我應該注意,通過使用上述方法,我假設代碼使用 PEAR 命名方案(就像 ZF).
I should note that by using the above method, I'm assuming the code uses the PEAR naming scheme (just like ZF).
這篇關于將 3rd 方庫添加到 ZendFramework的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!