我的问题很简单:
如何添加 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模板网!